Доброго времени суток. Сделал таск в gulp:
var path = require('path');
var gulp = require('gulp');
var spawn = require("gulp-spawn");
gulp.task('snapshot', function(){
gulp.src('snapshot.js')
.pipe(spawn({
cmd: "phantomjs",
args: [
"snapshot.js",
"http://localhost:3000/#/index/",
"index"
]
}));
});
Этот таск запускает в фантом js файл с парсингом страницы
Файл фантом:
var page = require('webpage').create();
var system = require('system');
var fs = require('fs');
var url = system.args[1];
var name = system.args[2];
page.open(url, function () {
fs.write('snapshot/'+name+'.html', page.frameContent, 'w');
phantom.exit();
});
Отдельно файл отлично работает, а при запуске через gulp получаю ошибку:
events.js:85
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:746:11)
at Socket._writeGeneric (net.js:690:26)
at Socket._write (net.js:709:8)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at Socket.Writable.write (_stream_writable.js:217:11)
at Socket.write (net.js:634:40)
at PassThrough.stream._transform (d:\Project\rts-site\node_modules\gulp-spawn\index.js:84:18)
at PassThrough.Transform._read (_stream_transform.js:179:10)
at PassThrough.Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at PassThrough.Writable.write (_stream_writable.js:217:11)
at write (d:\Project\rts-site\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24)
at flow (d:\Project\rts-site\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (d:\Project\rts-site\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:664:5)
Process finished with exit code 1