node-glob
glob functionality for node.js
in Gulp, I have a glob pattern that I want to verify. For instance:
gulp.task('clean-requirejs', function() {
return gulp.src([
'./public/res-min/**/*.js'
])
.pipe(clean());
});
I want to see how the glob ['./public/res-min/**/*.js']
is expanded. How do I print the arguments/filelist which is generated by gulp.src
in this example?
UPDATE: Turns out there is a really simple gulp-print
which can solve the job like so:
var print = require('gulp-print');
[....]
.pipe(print());
Source: (StackOverflow)
this is my current code to copy relevant files from my source to my build dir. It does not work as expected
return gulp.src([
'src/**/*',
'!src/**/*(*.sass|*.scss|*.js)',
'!src/(components|config|elements|less|sass|scss|platforms)',
'src/console.js',
'src/cordova.js',
'src/config.xml',
]).pipe(plugins.copy("www", {prefix: 1}));
My idea is this:
- Select all files and folders in src
- Remove all js and sass files because they get compiled/concat/minified and copied to build in another task
- However console.js and cordova.js have to be copied, so i want to reinclude them into the glob
Well, i thought the elements order in the globArray is a priority or something so that e.g. console.js gets reincluded after it got filtered out. It doesnt seem so :(
What can i do?
Source: (StackOverflow)
I'd like to absolute paths with sindresorhus' node del plugin (or really node-glob
) but it doesn't seem to work. I tried fiddling around with node-glob's options like cwd
and root
, but didn't get it to work.
Any idea anyone? One of my attempts:
var path = require('path');
var del = require('del');
var root = path.resolve(__dirname, '..'); // this could be more involved..
var delOptions = {
cwd: root,
force: true
};
del([
'browser/dist/**',
], delOptions, function (err, paths) {
console.log('removed files:');
console.log('- ' + paths.join('\n- '));
});
Source: (StackOverflow)
I have a project that looks like this
ls foo/
- file0.js
- a/file1.js
- b/file2.js
- c/file3.js
- d/file4.js
How do I write a glob pattern to exclude the c & d folder but get all other javascript files? I have looked here for an example, but cannot get anything to work.
I imagine the solution would look similar to this:
glob('+(**/*.js|!(c|d))', function(err, file) {
return console.log(f);
});
I am wanting back
- file0.js
- a/file1.js
- b/file2.js
Source: (StackOverflow)
This question already has an answer here:
I'm trying to minify all the .js files inside a certain directory using grunt-contrib-uglify (latest).
This is the uglify configuration part from my GruntFile.js:
uglify: {
scripts: {
files: [{
expand: true,
cwd: 'src',
src: '**/*.js',
dest: 'dest',
ext: '.min.js'
}]
}
}
The thing is, It does not seem to match files names which contains dots in it - for example 'external.library.js' - won't be minified.
Any idea how to get this thing work?
Thanks!
Source: (StackOverflow)