gulp
gulp copied to clipboard
Unexpected results if the node project is located at path containing square brackets []
What were you expecting to happen?
Hi! I'm learning gulp and just wanted to try out a very basic usage, namely copying some files from one folder to another.
What actually happened?
Nothing. No message error, execution seems normal but I've observed no changes in the file structure.
Please give us a sample of your gulpfile
const {src,dest} = require("gulp");
exports.default = (fulfill) => {
return src("index.js").pipe(dest("output"));
}
Terminal output / screenshots
[11:20:47] Starting 'default'...
[11:20:47] Finished 'default' after 35 ms
Please provide the following information:
- Windows 7
- node version v12.18.2
- npm version 6.14.5
- CLI version: 2.3.0
- Local gulp version: 4.0.2
Additional information
After some testing I've realised that the culprit is the absolute path of the project itself, namely a folder that contained square brackets in the folder name.
For example the path of my node project is like this:
C:/[node]/projects/learning-gulp
When I copied the project to a location that doesn't contain square brackets, everything started to work as expected.
To make sure, I've done two additional tests. Placing the node project under the following path has exactly the same (= none) result:
C:/projects/[learning-gulp]
An interesting case though was when I removed one of the brackets. So for this path:
C:/projects/[learning-gulp
...as the result, the index.js was WAS copied, but under the output/[learning-gulp
folder instead of just output
.
So the absolute path of the copied file was:
C:/projects/[learning-gulp/output/[learning-gulp/index.js
Note:
I know this issue is similar to #2436 but note that in my case the problem are square brackets in the path "above" the gulpfile.js
, and not within the node project folder. My code also doesn't include paths with square brackets at any point, so the problem is not explicitly in the programmer's code, thus rendering it more difficult to detect, especially for new-comers to Gulp.
Whoa! That's definitely an issue. Thanks for pointing it out.
Just curious, why do people put square brackets in file paths? That's such an obscure pattern 😅
I was expecting that question :p I usually just keep my projects with all kinds of important stuff in a synchronised folder, like C:/[Synchronised]
. I wanted it to appear always on top of the list and be easily distinguishable, so I figured I can just wrap its name in square brackets. Seemed like a harmless idea at the time... Ha ha, but to be honest, it may sound surprising, but I really so rarely get any issues because of the square brackets that I hardly remember they're there.
This will be fixed in gulp v5 via glob-stream v8. See https://github.com/gulpjs/glob-stream/pull/117 for more information.