javascript - Using gulp with request -
i have following gulpfile.js
:
'use strict'; const gulp = require('gulp'), request = require('request'); const paths = { vendor: [ 'https://raw.githubusercontent.com/jquery/jquery-dist/master/dist/jquery.min.js', 'https://raw.githubusercontent.com/kenwheeler/slick/master/slick/slick.js' ] }; gulp.task('vendor', (res) => { const url = request.get(paths.vendor).pipe(res); return gulp.src(url) .pipe(gulp.dest('public/vendor')); }); gulp.task('default', gulp.parallel('vendor'));
i'm getting following error:
error: options.uri required argument
with method trying dicthing client-side package managers, bower. there way use request
gulp
, looping through list of object?
edit:
i placed code testing, returning first line loop:
gulp.task('vendor', () => { (let i=0; i<paths.vendor.length; i++) { return console.log(paths.vendor[i]); }; });
just like:
gulp.task('vendor', (res) => { const url = request.get(paths.vendor[index++]).pipe(res); return gulp.src(url) .pipe(gulp.dest('public/vendor')); });
you cannot pass url gulp.src()
. gulp
instance inherits src()
, dest()
vinyl-fs
meaning can use read , write local file system.
try gulp-download
instead, wraps request
vinyl stream:
var download = require('gulp-download'); gulp.task('vendor', () => { return download(paths.vendor) .pipe(gulp.dest('public/vendor')); });
Comments
Post a Comment