Permalink
Browse files

Fixes #22 - Prebuild when calling shifter --walk

  • Loading branch information...
1 parent a7c1f8e commit a7174d58cceac28c05cc4a53fd6afd2ecd8075d5 @davglass davglass committed Sep 24, 2012
Showing with 34 additions and 26 deletions.
  1. +34 −26 lib/watch.js
View
@@ -21,7 +21,7 @@ var log = require('./log'),
'.json': true
};
-var build = function (cwd) {
+var build = function (cwd, callback) {
if (buildRunning) {
log.warn('change detected while a build is in progress, you\'re too fast for me');
return false;
@@ -52,6 +52,9 @@ var build = function (cwd) {
} else {
log.info('build exited with ' + code + ' you are good to go');
}
+ if (callback) {
+ callback();
+ }
});
};
@@ -86,35 +89,40 @@ var handler = function (file, curr, prev) {
};
exports.start = function (options) {
- log.info('watching for shifts in ' + dirs.join(', '));
-
- quiet = options.quiet;
- if (quiet) {
- log.warn('shifting into quiet mode, only errors will be printed');
- }
+ log.info('shifting the first time for you..');
+ quiet = true;
+ build(process.cwd(), function () {
+ log.info('watching for shifts in ' + dirs.join(', '));
- var args = require('./args').raw();
- args.argv.original.forEach(function (arg) {
- if (arg !== '--watch') {
- buildArgs.push(arg);
+ quiet = options.quiet;
+ if (quiet) {
+ log.warn('shifting into quiet mode, only errors will be printed');
}
- });
- watch.createMonitor(process.cwd(), {
- ignoreDotFiles: true,
- filter: function (file) {
- var name = shorten(file),
- inDirs = dirs.some(function (d) {
- return (name.indexOf('./' + d) === 0) || name === d;
- });
- if (inDirs) {
- return false;
+ var args = require('./args').raw();
+ args.argv.original.forEach(function (arg) {
+ if (arg !== '--watch') {
+ buildArgs.push(arg);
}
- }
- }, function (monitor) {
- log.info('waiting for a gear to shift...');
- ['created', 'changed', 'updated'].forEach(function (event) {
- monitor.on(event, handler);
+ });
+
+ watch.createMonitor(process.cwd(), {
+ ignoreDotFiles: true,
+ filter: function (file) {
+ var name = shorten(file),
+ inDirs = dirs.some(function (d) {
+ return (name.indexOf('./' + d) === 0) || name === d;
+ });
+ if (inDirs) {
+ return false;
+ }
+ }
+ }, function (monitor) {
+ log.info('waiting for a gear to shift...\n');
+ ['created', 'changed', 'updated'].forEach(function (event) {
+ monitor.on(event, handler);
+ });
});
});
+
};

0 comments on commit a7174d5

Please sign in to comment.