phantomjs.js 934 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. src = config.phjs
  8. if (!src){
  9. var m=grunt.file.read(confDir+"location.js")
  10. var src=/= \"([^\"]*)\"/.exec(m)[1];
  11. if (!grunt.file.isPathAbsolute(src)) {
  12. src = confDir+src;
  13. }
  14. }
  15. try {
  16. grunt.config('copy.phantom_bin', {
  17. src: src,
  18. dest: dest,
  19. options: { mode: true},
  20. });
  21. grunt.task.run('copy:phantom_bin');
  22. } catch (err) {
  23. grunt.verbose.writeln(err);
  24. grunt.fail.warn('No working Phantomjs binary available')
  25. }
  26. } else {
  27. grunt.log.writeln('Phantomjs already imported from node');
  28. }
  29. });
  30. };