Skip to content

Commit

Permalink
Validate Karma config before starting watcher
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
jlmakes committed Feb 6, 2019
1 parent 7ef7ea0 commit cc9ad10
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/index.js
Expand Up @@ -7,7 +7,11 @@ const Watcher = require("./Watcher");
function createPreprocessor(preconfig, config, emitter, logger) {
const cache = new Map();
const log = logger.create("preprocessor.rollup");
const watcher = new Watcher(emitter);

let watcher;
if (!config.singleRun && config.autoWatch) {
watcher = new Watcher(emitter);
}

return async function preprocess(original, file, done) {
const location = path.relative(config.basePath, file.path);
Expand All @@ -25,8 +29,10 @@ function createPreprocessor(preconfig, config, emitter, logger) {
const bundle = await rollup.rollup(options);
cache.set(file.path, bundle.cache);

const [entry, ...dependencies] = bundle.watchFiles;
watcher.add(entry, dependencies);
if (watcher) {
const [entry, ...dependencies] = bundle.watchFiles;
watcher.add(entry, dependencies);
}

log.info("Generating bundle for ./%s", location);
const { output } = await bundle.generate(options);
Expand Down

0 comments on commit cc9ad10

Please sign in to comment.