phantomjs.js 995 B

123456789101112131415161718192021222324252627282930313233343536
  1. module.exports = function(config,grunt) {
  2. 'use strict';
  3. grunt.registerTask('phantomjs', 'Copy phantomjs binary from node', function() {
  4. var dest = './vendor/phantomjs/phantomjs';
  5. var confDir = './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/'
  6. if (!grunt.file.exists(dest)){
  7. var m=grunt.file.read(confDir+"location.js")
  8. var src=/= \"([^\"]*)\"/.exec(m)[1];
  9. if (!grunt.file.isPathAbsolute(src)) {
  10. src = confDir+src;
  11. }
  12. var exec = require('child_process').execFileSync;
  13. try {
  14. grunt.config('copy.phantom_bin', {
  15. src: src,
  16. dest: dest,
  17. options: { mode: true},
  18. });
  19. grunt.task.run('copy:phantom_bin');
  20. } catch (err) {
  21. grunt.verbose.writeln(err);
  22. grunt.fail.warn('No working Phantomjs binary available')
  23. }
  24. } else {
  25. grunt.log.writeln('Phantomjs already imported from node');
  26. }
  27. });
  28. };