Skip to content

Commit

Permalink
Closes #65 by checking that options.tasks has been set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Gariety committed Mar 20, 2015
1 parent 76cf738 commit 25c442a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
16 changes: 8 additions & 8 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ gulp.task('test', ['lint'], function () {
, watch: './'
, ext: 'js coffee'
// , tasks: ['lint']
, tasks: function (files) {
var tasks = []
files.forEach(function (file) {
if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint')
if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin')
})
return tasks
}
// , tasks: function (files) {
// var tasks = []
// files.forEach(function (file) {
// if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint')
// if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin')
// })
// return tasks
// }
// , nodeArgs: ['--debug']
})
.on('restart', 'cssmin')
Expand Down
28 changes: 15 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ module.exports = function (options) {
, originalOn = script.on

// Allow for injection of tasks on file change
if (options.verbose) {
script.on('log', function (log) {
if (~log.message.indexOf('files triggering change check')) {
if (typeof options.tasks === 'function') run(options.tasks(log.message.split('files triggering change check: ').pop().split(' ')))
else run(options.tasks)
}
})
} else {
script.on('log', function (log) {
if (~log.message.indexOf('restarting due to changes...')) {
run(options.tasks)
}
})
if (options.tasks) {
if (options.verbose) {
script.on('log', function (log) {
if (~log.message.indexOf('files triggering change check')) {
if (typeof options.tasks === 'function') run(options.tasks(log.message.split('files triggering change check: ').pop().split(' ')))
else run(options.tasks)
}
})
} else {
script.on('log', function (log) {
if (~log.message.indexOf('restarting due to changes...')) {
run(options.tasks)
}
})
}
}

// Capture ^C
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-nodemon",
"version": "2.0.1",
"version": "2.0.2",
"description": "it's gulp + nodemon + convenience",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion test/server.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log('foo')
console.log('foos')

0 comments on commit 25c442a

Please sign in to comment.