1

これが私のgulpfile.jsです

var gulp = require('gulp');
var download = require('gulp-download');
var unzip = require('unzip');

gulp.task('download-selenium', function(){
  download('https://selenium.googlecode.com/files/selenium-server-2.39.0.zip')
    .pipe(unzip.Extract({ path: 'selenium' }))
    .pipe(gulp.dest("selenium"));
});

起動すると、次の問題があります。

$ gulp download-selenium
[gulp] Using file /Users/toutpt/makina/nmd/carteeco/mockup/gulpfile.js
[gulp] Working directory changed to /Users/toutpt/makina/nmd/carteeco/mockup
[gulp] Running 'download-selenium'...
[gulp] Errored 'download-selenium' in 9.08 ms Cannot pipe. Not readable.

/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/node_modules/orchestrator/index.js:153
            throw err;
                  ^
Error: Cannot pipe. Not readable.
    at Extract.Writable.pipe (_stream_writable.js:125:22)
    at Gulp.gulp.task.server (/Users/toutpt/makina/nmd/carteeco/mockup/gulpfile.js:99:6)
    at module.exports (/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:31:7)
    at Gulp.Orchestrator._runTask (/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at Gulp.run (/Users/toutpt/makina/nmd/carteeco/mockup/node_modules/gulp/index.js:20:14)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:132:19
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)

では、ダウンロードしたファイルを抽出するにはどうすればよいですか?

4

2 に答える 2

1

gulp-downloadはもうメンテナンスされていないようで、gulp-gunzipにはより最新の例があります:

var gulp = require('gulp')
var request = require('request')
var source = require('vinyl-source-stream')
var gunzip = require('gulp-gunzip')
var untar = require('gulp-untar')

gulp.task('default', function () {
  return request('http://example.org/some-file.tar.gz')
  .pipe(source('some-file.tar.gz'))
  .pipe(gunzip())
  .pipe(untar())
  .pipe(gulp.dest('output'))
})
于 2015-08-13T16:04:44.293 に答える