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

Commit 731a73c

Browse files
committed
aaa
1 parent a540f83 commit 731a73c

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

bin/node-sass

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ function watch(options, emitter) {
290290
gaze.on('deleted', function() {
291291
graph = buildGraph(options);
292292
});
293+
294+
if (!options.quiet) {
295+
console.log('Watching', options.directory || options.src);
296+
}
293297
}
294298

295299
/**

test/cli.js

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,27 @@ describe('cli', function() {
304304

305305
it('should watch the full scss dep tree for a single file (scss)', function(done) {
306306
var src = fixture('watching/index.scss');
307-
var foo = fixture('watching/white.scss');
307+
var child = fixture('watching/white.scss');
308308

309309
var bin = spawn(cli, [
310310
'--output-style', 'compressed',
311311
'--watch', src
312312
]);
313313

314314
bin.stdout.setEncoding('utf8');
315-
bin.stdout.on('data', function(data) {
316-
assert.strictEqual(data.trim(), 'body{background:white}');
317-
bin.kill();
315+
bin.stdout.once('data', function() {
316+
touch(child, function() {
317+
bin.stdout.once('data', function(data) {
318+
assert.strictEqual(data.trim(), 'body{background:white}');
319+
bin.kill();
320+
});
321+
});
318322
});
319323
bin.on('error', function(err) {
320324
assert.fail(err);
321325
done();
322326
});
323327
bin.on('exit', done);
324-
325-
setTimeout(function() {
326-
touch.sync(foo);
327-
}, 500);
328328
}).timeout(5000);
329329

330330
it('should watch the full sass dep tree for a single file (sass)', function(done) {
@@ -337,9 +337,13 @@ describe('cli', function() {
337337
]);
338338

339339
bin.stdout.setEncoding('utf8');
340-
bin.stdout.once('data', function(data) {
341-
assert.strictEqual(data.trim(), 'body{background:white}');
342-
bin.kill();
340+
bin.stdout.once('data', function() {
341+
touch(child, function() {
342+
bin.stdout.once('data', function(data) {
343+
assert.strictEqual(data.trim(), 'body{background:white}');
344+
bin.kill();
345+
});
346+
});
343347
});
344348
bin.on('error', function(err) {
345349
assert.fail(err);
@@ -358,6 +362,7 @@ describe('cli', function() {
358362
var destDir = tmpDir({ create: true });
359363
var srcDir = fixture('watching-dir-01/');
360364
var srcFile = path.join(srcDir, 'index.scss');
365+
var w;
361366

362367
var bin = spawn(cli, [
363368
'--output-style', 'compressed',
@@ -366,24 +371,25 @@ describe('cli', function() {
366371
]);
367372

368373
bin.stdout.setEncoding('utf8');
369-
bin.stdout.once('data', function() {
370-
assert.fail('should not emit console output when watching a directory');
374+
bin.stdout.once('data', function(data) {
375+
assert.equal('Watching ' + srcDir, data.trim());
376+
touch(srcFile, function() {
377+
bin.stdout.once('data', function() {
378+
assert.fail('should not emit console output when watching a directory');
379+
});
380+
});
371381
});
372382
bin.on('error', assert.fail);
383+
bin.on('exit', w.close);
373384

374-
375-
fs.watch(destDir, once(function() {
385+
w = fs.watch(destDir, function() {
376386
bin.kill();
377387
fs.readdir(destDir, function(err, files) {
378388
assert.deepEqual(files, ['index.css']);
379389
rimraf(destDir, done);
380390
});
381-
}));
382-
383-
setTimeout(function() {
384-
touch.sync(srcFile);
385-
}, 500);
386-
});
391+
});
392+
}).timeout(5000);
387393

388394
it('should compile all changed files in watched directory', function(done) {
389395
var destDir = tmpDir({ create: true });
@@ -402,17 +408,16 @@ describe('cli', function() {
402408
});
403409
bin.on('error', assert.fail);
404410

405-
406-
fs.watch(destDir, once(function() {
407-
bin.kill();
408-
fs.readdir(destDir, function(err, files) {
409-
assert.deepEqual(files, ['foo.css', 'index.css']);
410-
rimraf(destDir, done);
411-
});
412-
}));
413-
414411
setTimeout(function() {
415-
touch.sync(srcFile);
412+
setTimeout(function() {
413+
bin.kill();
414+
fs.readdir(destDir, function(err, files) {
415+
assert.deepEqual(files, ['foo.css', 'index.css']);
416+
rimraf(destDir, done);
417+
});
418+
}, 1000);
419+
420+
spawn('node', ['-e', 'require("touch").sync("' + srcFile + '")']);
416421
}, 500);
417422
});
418423
});

0 commit comments

Comments
 (0)