From 25c442adf5738801c34b14d5917492a06561c67e Mon Sep 17 00:00:00 2001 From: Jackson Gariety Date: Thu, 19 Mar 2015 17:51:47 -0700 Subject: [PATCH] Closes #65 by checking that options.tasks has been set. --- Gulpfile.js | 16 ++++++++-------- index.js | 28 +++++++++++++++------------- package.json | 2 +- test/server.js | 2 +- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 9aa0817..5f0cbb6 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -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') diff --git a/index.js b/index.js index 522ae6c..a755160 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/package.json b/package.json index d1b3206..3922ee4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/server.js b/test/server.js index a5b9709..db99ffc 100644 --- a/test/server.js +++ b/test/server.js @@ -1 +1 @@ -console.log('foo') +console.log('foos')