Reputation: 1532
Given the following Gulp setup
const { src, dest } = require('gulp');
var zip = require('gulp-zip');
var pkgDist = 'packages/';
function pkg(done) {
src(['./**', '!node_modules/**', '!vendor/**', '!.gitignore', '!*.json', '!*.lock'], {base: '..'})
.pipe(zip('archive.zip'))
.pipe(dest(pkgDist))
done();
};
exports.pkg = pkg;
how can I modify it in order to get src
globs from a variable, i.e. pkgSrc
, something like this:
[...]
var pkgSrc = <what to put here?>;
[...]
src(pkgSrc)
[...]
I've tried to use this var pkgSrc = " ['./**', '!node_modules/**', '!vendor/**', '!.gitignore', '!*.json', '!*.lock'], {base: '..'} ";
but it doesn't work.
If it's easier, I'm also open to solutions that result into this src([pkgSrc], {base: '..'})
Upvotes: 0
Views: 173
Reputation: 180885
You can go with just:
var pkgSrc = ['./**', '!node_modules/**', '!vendor/**', '!.gitignore', '!*.json', '!*.lock']
gulp.src
first argument can be a string or an array, so now it is an array above.
The second argument is an object of options. Include the options sepearately: {base: '..'}
so
src(pkgSrc, {base: '..'})
Upvotes: 2