Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit bd1d246

Browse files
committed
Watch as a boolean
1 parent fb5c2a4 commit bd1d246

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

bin/node-sass

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ var cli = meow({
5353
'recursive',
5454
'source-map-embed',
5555
'source-map-contents',
56-
'source-comments'
56+
'source-comments',
57+
'watch'
5758
],
5859
string: [
5960
'functions',
@@ -64,8 +65,7 @@ var cli = meow({
6465
'output',
6566
'output-style',
6667
'precision',
67-
'source-map-root',
68-
'watch'
68+
'source-map-root'
6969
],
7070
alias: {
7171
c: 'source-comments',
@@ -139,7 +139,7 @@ function getEmitter() {
139139
*/
140140

141141
function getOptions(args, options) {
142-
options.src = args[0] || options.watch;
142+
options.src = args[0];
143143

144144
if (args[1]) {
145145
options.dest = path.resolve(process.cwd(), args[1]);
@@ -161,30 +161,14 @@ function getOptions(args, options) {
161161
*/
162162

163163
function watch(options, emitter) {
164-
var watchDir = isSassFile(options.watch) ? path.dirname(path.resolve(options.watch)) : options.watch,
165-
glob = options.recursive ? '**/*.{sass,scss}' : '*.{sass,scss}',
166-
gaze = new Gaze(),
167-
dir;
168-
169-
if (watchDir === true) {
170-
dir = [];
171-
} else if (!Array.isArray(watchDir)) {
172-
dir = [watchDir];
173-
}
174-
175-
// only add the src file if it is not already
176-
// in the array as the watch path
177-
if (options.watch !== options.src) {
178-
dir.push(options.src);
179-
}
180-
dir = dir.map(function(d) {
181-
return isSassFile(d) ? d : path.join(d, glob);
182-
});
164+
var glob = options.recursive ? '**/*.{sass,scss}' : '*.{sass,scss}';
165+
var src = isSassFile(options.src) ? options.src : path.join(options.src, glob);
166+
var gaze = new Gaze();
183167

184-
gaze.add(dir);
168+
gaze.add(src);
185169
gaze.on('error', emitter.emit.bind(emitter, 'error'));
186170

187-
var graph = grapher.parseDir(watchDir, { loadPaths: options.includePath });
171+
var graph = grapher.parseDir(path.resolve(path.dirname(src)), { loadPaths: options.includePath });
188172

189173
gaze.on('changed', function(file) {
190174
var files = [file];

test/cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ describe('cli', function() {
222222
bin.stdout.setEncoding('utf8');
223223
bin.stdout.once('data', function(data) {
224224
assert(data.trim() === 'body{background:white}');
225-
fs.unlinkSync(fixtures('watching/index.css'));
226225
done();
227226
});
228227

0 commit comments

Comments
 (0)