From bd1d246f03e475b230c69985dbf67eca9d3f74a4 Mon Sep 17 00:00:00 2001 From: Wes Todd Date: Sat, 28 Mar 2015 18:55:28 -0500 Subject: [PATCH] Watch as a boolean --- bin/node-sass | 34 +++++++++------------------------- test/cli.js | 1 - 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/bin/node-sass b/bin/node-sass index bd09b9c1a..566c2e386 100755 --- a/bin/node-sass +++ b/bin/node-sass @@ -53,7 +53,8 @@ var cli = meow({ 'recursive', 'source-map-embed', 'source-map-contents', - 'source-comments' + 'source-comments', + 'watch' ], string: [ 'functions', @@ -64,8 +65,7 @@ var cli = meow({ 'output', 'output-style', 'precision', - 'source-map-root', - 'watch' + 'source-map-root' ], alias: { c: 'source-comments', @@ -139,7 +139,7 @@ function getEmitter() { */ function getOptions(args, options) { - options.src = args[0] || options.watch; + options.src = args[0]; if (args[1]) { options.dest = path.resolve(process.cwd(), args[1]); @@ -161,30 +161,14 @@ function getOptions(args, options) { */ function watch(options, emitter) { - var watchDir = isSassFile(options.watch) ? path.dirname(path.resolve(options.watch)) : options.watch, - glob = options.recursive ? '**/*.{sass,scss}' : '*.{sass,scss}', - gaze = new Gaze(), - dir; - - if (watchDir === true) { - dir = []; - } else if (!Array.isArray(watchDir)) { - dir = [watchDir]; - } - - // only add the src file if it is not already - // in the array as the watch path - if (options.watch !== options.src) { - dir.push(options.src); - } - dir = dir.map(function(d) { - return isSassFile(d) ? d : path.join(d, glob); - }); + var glob = options.recursive ? '**/*.{sass,scss}' : '*.{sass,scss}'; + var src = isSassFile(options.src) ? options.src : path.join(options.src, glob); + var gaze = new Gaze(); - gaze.add(dir); + gaze.add(src); gaze.on('error', emitter.emit.bind(emitter, 'error')); - var graph = grapher.parseDir(watchDir, { loadPaths: options.includePath }); + var graph = grapher.parseDir(path.resolve(path.dirname(src)), { loadPaths: options.includePath }); gaze.on('changed', function(file) { var files = [file]; diff --git a/test/cli.js b/test/cli.js index 1ee588fab..0310fbd26 100644 --- a/test/cli.js +++ b/test/cli.js @@ -222,7 +222,6 @@ describe('cli', function() { bin.stdout.setEncoding('utf8'); bin.stdout.once('data', function(data) { assert(data.trim() === 'body{background:white}'); - fs.unlinkSync(fixtures('watching/index.css')); done(); });