phantomjs.js 845 B

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