phantomjs.js 908 B

12345678910111213141516171819202122232425262728293031323334
  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/phantomjs-prebuilt/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. try {
  13. grunt.config('copy.phantom_bin', {
  14. src: src,
  15. dest: dest,
  16. options: { mode: true},
  17. });
  18. grunt.task.run('copy:phantom_bin');
  19. } catch (err) {
  20. grunt.verbose.writeln(err);
  21. grunt.fail.warn('No working Phantomjs binary available')
  22. }
  23. } else {
  24. grunt.log.writeln('Phantomjs already imported from node');
  25. }
  26. });
  27. };