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

Commit

Permalink
aaa
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyfer committed Feb 23, 2017
1 parent a540f83 commit a4ddbdb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
4 changes: 4 additions & 0 deletions bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ function watch(options, emitter) {
gaze.on('deleted', function() {
graph = buildGraph(options);
});

if (!options.quiet) {
console.log('Watching', options.directory || options.src);
}
}

/**
Expand Down
64 changes: 33 additions & 31 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,19 @@ describe('cli', function() {
]);

bin.stdout.setEncoding('utf8');
bin.stdout.on('data', function(data) {
assert.strictEqual(data.trim(), 'body{background:white}');
bin.kill();
bin.stdout.once('data', function() {
touch(foo, function() {
bin.stdout.once('data', function(data) {
assert.strictEqual(data.trim(), 'body{background:white}');
bin.kill();
});
});
});
bin.on('error', function(err) {
assert.fail(err);
done();
});
bin.on('exit', done);

setTimeout(function() {
touch.sync(foo);
}, 500);
}).timeout(5000);

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

bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) {
assert.strictEqual(data.trim(), 'body{background:white}');
bin.kill();
bin.stdout.once('data', function() {
touch(foo, function() {
bin.stdout.once('data', function(data) {
assert.strictEqual(data.trim(), 'body{background:white}');
bin.kill();
});
});
});
bin.on('error', function(err) {
assert.fail(err);
Expand Down Expand Up @@ -371,19 +375,18 @@ describe('cli', function() {
});
bin.on('error', assert.fail);


fs.watch(destDir, once(function() {
bin.kill();
fs.readdir(destDir, function(err, files) {
assert.deepEqual(files, ['index.css']);
rimraf(destDir, done);
});
}));

setTimeout(function() {
touch.sync(srcFile);
setTimeout(function() {
bin.kill();
fs.readdir(destDir, function(err, files) {
assert.deepEqual(files, ['index.css']);
rimraf(destDir, done);
});
}, 1000);

spawn('node', ['-e', 'require("touch").sync("' + srcFile + '")']);
}, 500);
});
}).timeout(5000);

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


fs.watch(destDir, once(function() {
bin.kill();
fs.readdir(destDir, function(err, files) {
assert.deepEqual(files, ['foo.css', 'index.css']);
rimraf(destDir, done);
});
}));

setTimeout(function() {
touch.sync(srcFile);
setTimeout(function() {
bin.kill();
fs.readdir(destDir, function(err, files) {
assert.deepEqual(files, ['foo.css', 'index.css']);
rimraf(destDir, done);
});
}, 1000);

spawn('node', ['-e', 'require("touch").sync("' + srcFile + '")']);
}, 500);
});
});
Expand Down

0 comments on commit a4ddbdb

Please sign in to comment.