phantomjs.js 777 B

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