Strange behavior of changing working directory.
See original GitHub issueI found a strange behavior about changing working directory. This is related to the comment in #109.
Assuming directory structure:
project/
├── gulpfile.js
└── currentdir/
├── .gulp.js
└── gulpfile-2.js
and the contents of each files:
$ cat currentdir/.gulp.js
module.exports = {
flags: {
gulpfile: './gulpfile-2.js'
}
}
$ cat currentdir/gulpfile-2.js
var gulp = require('gulp');
gulp.task('default', function() {
console.log(__filename);
});
$ cat gulpfile.js
var gulp = require('gulp');
gulp.task('default', function() {
console.log(__filename);
});
In this condition, the following execution uses project/gulpfile.js
against my intention.
$ cd currentdir/
$ gulp
[15:36:42] Working directory changed to ~/project
[15:36:42] Using gulpfile ~/project/gulpfile.js
[15:36:42] Starting 'default'...
/Users/sttk/project/gulpfile.js
[15:36:42] Finished 'default' after 141 μs
When project/gulpfile.js
is removed or renamed, project/currentdir/gulpfile-2.js
is used along my intention.
$ mv ../gulpfile.js ../gulpfile.js.x
$ gulp
[15:41:05] Using gulpfile ~/project/currentdir/gulpfile-2.js
[15:41:05] Starting 'default'...
/Users/sttk/project/currentdir/gulpfile-2.js
[15:41:05] Finished 'default' after 95 μs
This cause is that gulp found up project/gulpfile.js
and changed changed cwd
to project/
before finding and applying config files.cwd
for finding a config file to project/
in liftoff.
I think when a gulpfile is specified in a config file, I think that cwd
should be set back to INIT_CWD
or set to parent directory of the gulpfile.process.INIT_CWD
should be added to the directories for finding config files.
EDIT: I modified the last two sentences.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@phated I’ve just merged v2.0.1 to my repository, and I’m going to address this issue from now.
@sttk still planning to fix this?