Skip to content
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

Doesn't support locally installed gulp #134

Closed
dmm opened this issue Dec 28, 2016 · 2 comments
Closed

Doesn't support locally installed gulp #134

dmm opened this issue Dec 28, 2016 · 2 comments

Comments

@dmm
Copy link
Contributor

dmm commented Dec 28, 2016

gulp-nodemon implements synchronously running tasks on restart by launching gulp using spawnSync:

 function run(tasks) {
    if (typeof tasks === 'string') tasks = [tasks]
    if (tasks.length === 0) return
    if (!(tasks instanceof Array)) throw new Error('Expected task name or array but found: ' + tasks)
    cp.spawnSync(process.platform === 'win32' ? 'gulp.cmd' : 'gulp', tasks, { stdio: [0, 1, 2] })          // <==!
}

When gulp is installed globally spawnSync finds gulp in the PATH and runs it but when gulp is locally installed in "node_modules/.bin/" spawnSync fails with ENOENT because it can't find gulp.

To me it seems like you want to always use the locally installed gulp, the same version you're using when you require('gulp'). To achieve this we can do something like:

 function run(tasks) {
    if (typeof tasks === 'string') tasks = [tasks]
    if (tasks.length === 0) return
    if (!(tasks instanceof Array)) throw new Error('Expected task name or array but found: ' + tasks)
    var gulpPath = path.join(process.cwd(), 'node_modules/.bin/') 
    var gulpCmd = path.join(gulpPath, process.platform === 'win32' ? 'gulp.cmd' : 'gulp') 
    cp.spawnSync(gulpCmd, tasks, { stdio: [0, 1, 2] })          // <==!
}

What do you think of this? It's a pretty small change but I can make a pull request if you'd like.

@enaeseth
Copy link

enaeseth commented Jan 7, 2017

@dmm until #135 lands, the good news is that if you run gulp via yarn run or npm run, the local node_modules/.bin is placed at the beginning of $PATH, and the local gulp should be used anyway 😊

@dmm
Copy link
Contributor Author

dmm commented Jan 7, 2017

That makes sense. I was just confused as to why my tasks weren't running when manually running gulp.

Maybe the real issue is that not checking the return value of spawnSync ?

@dmm dmm closed this as completed Jan 10, 2017
ColemanGariety pushed a commit that referenced this issue Jan 13, 2018
Use locally installed gulp to run tasks. issue #134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants