mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-20 01:25:16 +00:00
28 lines
470 B
JavaScript
28 lines
470 B
JavaScript
var Q = require('q');
|
|
var path = require('path');
|
|
var Gaze = require('gaze').Gaze;
|
|
|
|
function watch(dir) {
|
|
var d = Q.defer();
|
|
dir = path.resolve(dir);
|
|
|
|
var gaze = new Gaze("**/*.md", {
|
|
cwd: dir
|
|
});
|
|
|
|
gaze.once("all", function(e, filepath) {
|
|
gaze.close();
|
|
|
|
d.resolve(filepath);
|
|
});
|
|
gaze.once("error", function(err) {
|
|
gaze.close();
|
|
|
|
d.reject(err);
|
|
});
|
|
|
|
return d.promise;
|
|
}
|
|
|
|
module.exports = watch;
|