Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 14, 2022
1 parent d06de28 commit 8f85dfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
16 changes: 6 additions & 10 deletions cli/run/watch-cli.ts
Expand Up @@ -19,8 +19,6 @@ export async function watch(command: Record<string, any>): Promise<void> {
process.env.ROLLUP_WATCH = 'true';
const isTTY = process.stderr.isTTY;
const silent = command.silent;
let configs: MergedRollupOptions[];
let warnings: BatchWarnings;
let watcher: RollupWatcher;
let configWatcher: FSWatcher;
let resetScreen: (heading: string) => void;
Expand Down Expand Up @@ -52,17 +50,15 @@ export async function watch(command: Record<string, any>): Promise<void> {
stderr(`\nReloading updated config...`);
}
configFileData = newConfigFileData;
const parsedConfig = await loadAndParseConfigFile(configFile, command);
const { options, warnings } = await loadAndParseConfigFile(configFile, command);
if (currentConfigFileRevision !== configFileRevision) {
return;
}
if (watcher) {
watcher.close();
}
({ options: configs, warnings } = parsedConfig);
start(configs);
start(options, warnings);
} catch (err: any) {
configs = [];
handleError(err, true);
}
}
Expand All @@ -71,11 +67,11 @@ export async function watch(command: Record<string, any>): Promise<void> {
if (configFile) {
await loadConfigFromFileAndTrack(configFile);
} else {
({ options: configs, warnings } = await loadConfigFromCommand(command));
start(configs);
const { options, warnings } = await loadConfigFromCommand(command);
start(options, warnings);
}

function start(configs: MergedRollupOptions[]): void {
function start(configs: MergedRollupOptions[], warnings: BatchWarnings): void {
try {
watcher = rollup.watch(configs as any);
} catch (err: any) {
Expand All @@ -92,7 +88,7 @@ export async function watch(command: Record<string, any>): Promise<void> {
case 'START':
if (!silent) {
if (!resetScreen) {
resetScreen = getResetScreen(configs!, isTTY);
resetScreen = getResetScreen(configs, isTTY);
}
resetScreen(underline(`rollup v${rollup.VERSION}`));
}
Expand Down
Expand Up @@ -6,7 +6,6 @@ const configFile = path.join(__dirname, 'rollup.config.js');
let stopUpdate;

module.exports = {
repeat: 100,
description: 'immediately reloads the config file if a change happens while it is parsed',
command: 'rollup -cw',
before() {
Expand Down

0 comments on commit 8f85dfa

Please sign in to comment.