-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grunt.file.expand() equivalent in gulp #386
Comments
@niki4810 You can pass globs into src, there is no need to "expand". For your example: gulp.src(['foo/**/*.js', 'bar/**/*.js']) or if you still needed to do it programmatically for some reason, here is an exact copy of what your stuff is doing var path = require('path');
var folders = ['foo', 'bar'];
var globs = folders.map(function(folder){
return path.join('../', folder, '**/*.js');
});
gulp.src(globs).pipe(stuff()) |
@contra : Here is a exact scenario on why I need to expand the file paths. When compile stylus files, I have a case where each stylus file goes to a separate destination folder. To do this, currently I am doing something like this :
In the above case, each source file needs to map to a specific destination. if each path in the Also, not sure what I did is an anti-pattern in gulp, i.e. using |
@niki4810 I'm convinced you can do it all in one .src run Give this a try and see if it does what you need var path = require('path');
var mainSrcPath = 'src/main';
var distPath = 'src/dist';
var folders = ['foo', 'bar'];
var glob = '../' + mainSrcPath + '/{' + folders.join(',') + '}/**/*.styl';
gulp.src(glob)
.pipe(stylus())
.pipe(gulp.dest(distPath)); |
If every folder beneath src/main is a folder containing stylus folders you dont even have to do anything fancy gulp.src('src/main/**/*.styl')
.pipe(stylus())
.pipe(gulp.dest('src/dist')); |
@contra: Thanks for your solution, it did work, but its still does not fit my use case. Basically if my directory structure is :
I wanted my generated styles per module to be with in
So for every module, the styl file under The reason I was looping over the paths was because my dest is different per each source module. |
Seems like a gulp-stylus feature request. I think the more typical use-case is for the styl files to be combined. |
gulp.src('./*/src/main/**/*.styl')
.pipe(stylus())
.pipe(rename(function(path){
path.dirname = path.dirname.replace('src/main', 'src/gen');
})
.pipe(gulp.dest('.')); See if that does it? |
@contra : That solution worked for me.. Thanks a lot for all your help 👍 |
Can you take a look at this thanks: http://stackoverflow.com/questions/24767080/package-files-by-folder-with-gulp |
Hi,
I am just getting started with gulp and need help with the following:
I was trying to achieve the same using gulp, i.e. get an array of all the .js files that match a pattern, what is the easiest way to achieve this in gulp?
Thanks
The text was updated successfully, but these errors were encountered: