Skip to content

Commit

Permalink
Merge pull request #120 from gabeboning/feature/watch-stylesheet
Browse files Browse the repository at this point in the history
Feature: watch stylesheet if passed with --style arg and reload on stylesheet change
  • Loading branch information
jdan committed Jun 27, 2015
2 parents 53011dd + 32795bf commit d1a8c7e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/cleaver
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ program
.description('Watch for changes on markdown file')
.action(function () {
var file = program.args[0];
createAndSave([file], getOptions());

var options = getOptions();
createAndSave([file], options);

console.log('Watching for changes on ' + file + '. Ctrl-C to abort.');
fs.watchFile(file, { persistent: true, interval: 100 }, function () {
console.log('Rebuilding: ' + new Date());
createAndSave([file], getOptions());
createAndSave([file], options);
});

// also watch on stylesheet if included via command prompt
if ('style' in options) {
console.log('Also watching for changes on ' + options.style);
fs.watchFile(options.style, { persistent: true, interval: 100 }, function () {
console.log('Rebuilding: ' + new Date());
createAndSave([file], options);
});
}
});


Expand Down

0 comments on commit d1a8c7e

Please sign in to comment.