My src folder contains both *.js files and *.min.js files. I just need to delete all files leaving *.min.js files intact using gulp. I tried this
return del.sync([
'js/**/*',
'!js/**/*.min.js']);
But this deletes all files in the src folder how do I proceed. considering that the src folder also contains other formats other than js
Related
Gulp: see below as an example
How to copy files ending with .html in a directory and its subdirectories?
How to copy files that not ending with .js in a directory and its subdirectories.
--dirA
--dirB
--b.html
--b.js
--dirC
--c.html
--index.html
Like jacmoe answered, if you need to get specific files in gulp, use that kind of syntax:
'/directory/*.fileextension' //Get all files in directory with .extension
'!/directory*.fileextension' //Ignore files with .extension
'/directory/**/*.fileextension' //Get all files in directory AND all subdirectories with .extension
And remember that gulp paths support arrays so you can write something like that:
['!/directory/**/*.js', '/directory/**/*'] //Get all files except .js files
Or if needed only specific files:
['/directory/**/*.html'] //Get all .html files
If I am not totally mistaken:
gulp.task('copyHTML', function() {
return gulp.src('directory/**/*.html')
.pipe(gulp.dest('copied/html'));
});
That code will copy any file ending in .html in any directory beneath the directory directory.
I have a folder structure like this
ProjectX
.......|_____node_modules
.......|_____src
.......|_____build
.......|_____app
.......|_____libraries
I have written a glob pattern in grunt browserify something like this
src:['**/*.js','!node_modules','!build'],
dest:'build/build.js'
What i want from above code is, all .js files in my project should be browserified except the .js files in 'node_modules' and 'build' folder.
But what actually is happening is still the files from node_modules and build folder are browserified in my 'build/build.js' destination.
And i do not want to specify folder names of the .js file i require. I do not want to do something like this
['src/**/*.js' ... etc]
How can i solve this problem?
I am new to gulp.
I have a directory in /src which I want to move to /dist.
My directory looks like this with a depth of more than 1.
folder1
- folder2
-folder4
-folder5
-folder6
-folder7
-folder8
-folder10
-folder9
- folder3
I have declared src path as /src/folder1/* in gulp file and it has moved only folder1,folder2,folder3 to the destination path.folder2 and folder3 are empty folders which is perfectly fine.
I have declared src path as /src/folder/** in gulp file and it has moved all the folders as expected to the destination path.And while I was going through all the folders in destination path after running gulpfile, it crashed with segmentation11.What is the reason for this?
And what is the actual method to move all the folders of above structure in gulp?
This is the behavior of node-glob which gulp uses under the hood. From their readme:
* Matches 0 or more characters in a single path portion
..
** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does
not crawl symlinked directories.
* will match everything in the same directory.
** will match everything recursively (subdirectories).
The segmentation fault is most likely due to a flaw in your script.
I am writing a SSIS package, and at one point I am working with a certain folder that I know the path for, and need to delete a folder inside that, but I don't know the name (path) of the inner folder.
So for example, I know this path: C:\Known, but there will be a folder inside 'Known' that I would like to delete. Like C:\Known\ Unknown
I can't use a File System Task and delete the unwanted folder, because I don't know the name of the folder, and I can't use a File System Task to delete all the directory contents of 'C:\Known', because it also contains .jpeg files that I need to keep.
Any thoughts? A solution to get the name of the Unknown folder, or delete any folders inside 'C:\Known' is acceptable.
You can add this code to a Script Task to delete all subdirectories in a path while not deleting any other file types:
foreach (string subdirectoryPath in Directory.GetDirectories(knownPath, "*", SearchOption.AllDirectories))
{
Directory.Delete(subdirectoryPath);
}
I have the following file hierarchy:
scripts
someConfigFile.js
anotherConfigFile.js
someModuleDirectory
someModule.js
anotherModuleDirectory
anotherModule.js
subDirectory
thirdModule.js
I want to match all the files in the module directories, but excude the config files contained in the scripts directory itself, using Glob:
var glob = require('glob');
console.log(glob.sync(unknownGlobPattern));
Required output (unordered):
[
'someModuleDirectory/someModule.js',
'anotherModuleDirectory/anotherModule.js',
'anotherModuleDirectory/subDirectory/thirdModule.js'
]
The following glob should work:
['./scripts/**/*', '!./scripts/*']
First part will include all files in all subdirectories. Second part will exclude files in starting directory.