Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more logging to provide better feedback #39

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/index.js
Expand Up @@ -6,7 +6,7 @@ const chokidar = require("chokidar");

function createPreprocessor(options, preconfig, basePath, emitter, logger) {
const log = logger.create("preprocessor.rollup");
const watch = new Watch(emitter);
const watch = new Watch(emitter, log);

let cache;

Expand All @@ -19,6 +19,7 @@ function createPreprocessor(options, preconfig, basePath, emitter, logger) {
.then(bundle => {
cache = bundle;
watch.capture(bundle);
log.info("Generating bundle");
return bundle.generate(config);
})
.then(({ code, map }) => {
Expand All @@ -45,11 +46,14 @@ function createPreprocessor(options, preconfig, basePath, emitter, logger) {
};
}

function Watch(emitter) {
function Watch(emitter, log) {
this.buffer = new Set();
this.watchList = new Set();
this.watch = chokidar.watch();
this.watch.on("change", () => emitter.refreshFiles());
this.watch.on("change", () => {
log.info('Change detected');
emitter.refreshFiles();
});
emitter.on("run_start", () => this.start());
}

Expand Down