Skip to content

Commit

Permalink
Merge pull request #151 from cnshenj/master
Browse files Browse the repository at this point in the history
Update gulp to 4.x.x
  • Loading branch information
clmn authored May 31, 2018
2 parents c49b947 + c1ef02d commit d087b15
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
15 changes: 9 additions & 6 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ var gulp = require('gulp')
// })

gulp.task('lint', function (){
gulp.src('./*/**.js')
return gulp.src('./*/**.js')
.pipe(jshint())
})

gulp.task('cssmin', function (){ /* void */
gulp.task('cssmin', function (done){
done();
})

gulp.task('afterstart', function (){
console.log('proc has finished restarting!')
gulp.task('afterstart', function (done){
console.log('proc has finished restarting!');
done();
})

gulp.task('test', ['lint'], function () {
gulp.task('test', gulp.series('lint', function (done){
var stream = nodemon({
nodemon: require('nodemon')
, script: './test/server.js'
Expand All @@ -31,6 +33,7 @@ gulp.task('test', ['lint'], function () {
}
, watch: './'
, ext: 'js coffee'
, done: done
})

stream
Expand All @@ -42,4 +45,4 @@ gulp.task('test', ['lint'], function () {
stream.emit('restart')
}, 2000)
})
})
}))
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ You can pass an object to gulp-nodemon with options [like you would in nodemon c

Example below will start `server.js` in `development` mode and watch for changes, as well as watch all `.html` and `.js` files in the directory.
```js
gulp.task('start', function () {
gulp.task('start', function (done) {
nodemon({
script: 'server.js'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
, done: done
})
})
```
Expand Down Expand Up @@ -93,11 +94,12 @@ gulp.task('lint', function () {
.pipe(jshint())
})

gulp.task('develop', function () {
gulp.task('develop', function (done) {
var stream = nodemon({ script: 'server.js'
, ext: 'html js'
, ignore: ['ignored.js']
, tasks: ['lint'] })
, done: done

stream
.on('restart', function () {
Expand All @@ -123,7 +125,7 @@ gulp.task('pluggable', function() {
The [bunyan](https://github.com/trentm/node-bunyan/) logger includes a `bunyan` script that beautifies JSON logging when piped to it. Here's how you can you can pipe your output to `bunyan` when using `gulp-nodemon`:

```js
gulp.task('run', ['default', 'watch'], function() {
gulp.task('run', ['default', 'watch'], function(done) {
var nodemon = require('gulp-nodemon'),
spawn = require('child_process').spawn,
bunyan
Expand All @@ -137,7 +139,8 @@ gulp.task('run', ['default', 'watch'], function() {
],
watch: [paths.etc, paths.src],
stdout: false,
readable: false
readable: false,
done: done
})
.on('readable', function() {

Expand Down Expand Up @@ -181,11 +184,12 @@ gulp.task('compile', function () {
return stream // important for gulp-nodemon to wait for completion
})

gulp.task('watch', ['compile'], function () {
gulp.task('watch', ['compile'], function (done) {
var stream = nodemon({
script: 'dist/' // run ES5 code
, watch: 'src' // watch ES2015 code
, tasks: ['compile'] // compile synchronously onChange
, done: done
})

return stream
Expand Down
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ module.exports = function (options) {
}

// Capture ^C
var exitHandler = function (options){
if (options.exit) script.emit('exit')
if (options.quit) process.exit(0)
}
process.once('exit', exitHandler.bind(null, { exit: true }))
process.once('SIGINT', exitHandler.bind(null, { quit: true }))
process.once('SIGINT', function () {
script.emit('quit')
script.quitEmitted = true
})
script.on('exit', function () {
// Ignore exit event during restart
if (script.quitEmitted) {
// Properly signal async completion by calling the callback provided by gulp
if (typeof options.done === "function") {
options.done()
}

process.exit(0)
}
})

// Forward log messages and stdin
script.on('log', function (log){
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-nodemon",
"version": "2.3.0",
"version": "3.0.0",
"description": "it's gulp + nodemon + convenience",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -28,10 +28,10 @@
},
"homepage": "https://github.com/JacksonGariety/gulp-nodemon",
"dependencies": {
"colors": "^1.0.3",
"event-stream": "^3.2.1",
"gulp": "^3.9.1",
"nodemon": "^1.10.2"
"colors": "^1.2.1",
"event-stream": "^3.3.4",
"gulp": "^4.0.0",
"nodemon": "^1.17.3"
},
"devDependencies": {
"should": "^4.0.0",
Expand Down

0 comments on commit d087b15

Please sign in to comment.