2016-09-18 04:13:00 -05:00
|
|
|
module.exports = function(config,grunt) {
|
|
|
|
'use strict';
|
|
|
|
|
2016-09-18 06:45:46 -05:00
|
|
|
grunt.registerTask('phantomjs', 'Copy phantomjs binary to vendor/', function() {
|
2016-09-18 04:13:00 -05:00
|
|
|
|
|
|
|
var dest = './vendor/phantomjs/phantomjs';
|
|
|
|
var confDir = './node_modules/phantomjs-prebuilt/lib/';
|
|
|
|
|
2017-01-25 07:49:09 -06:00
|
|
|
if (process.platform === "win32") {
|
|
|
|
dest += ".exe";
|
|
|
|
}
|
|
|
|
|
2016-09-18 06:45:46 -05:00
|
|
|
src = config.phjs
|
2016-09-18 04:13:00 -05:00
|
|
|
|
2016-09-18 06:45:46 -05:00
|
|
|
if (!src){
|
|
|
|
var m=grunt.file.read(confDir+"location.js")
|
|
|
|
var src=/= \"([^\"]*)\"/.exec(m)[1];
|
2016-09-18 04:13:00 -05:00
|
|
|
|
2016-09-18 06:45:46 -05:00
|
|
|
if (!grunt.file.isPathAbsolute(src)) {
|
|
|
|
src = confDir+src;
|
2016-09-18 04:13:00 -05:00
|
|
|
}
|
2016-09-18 06:45:46 -05:00
|
|
|
}
|
2016-09-18 04:13:00 -05:00
|
|
|
|
2016-09-18 06:45:46 -05:00
|
|
|
try {
|
|
|
|
grunt.config('copy.phantom_bin', {
|
|
|
|
src: src,
|
|
|
|
dest: dest,
|
|
|
|
options: { mode: true},
|
|
|
|
});
|
|
|
|
grunt.task.run('copy:phantom_bin');
|
|
|
|
} catch (err) {
|
|
|
|
grunt.verbose.writeln(err);
|
|
|
|
grunt.fail.warn('No working Phantomjs binary available')
|
2016-09-18 04:13:00 -05:00
|
|
|
}
|
2016-09-18 06:45:46 -05:00
|
|
|
|
2016-09-18 04:13:00 -05:00
|
|
|
});
|
|
|
|
};
|