Skip to content

Commit 6ee0d6b

Browse files
committed
feat(automd): expose unwatch
1 parent 361cd50 commit 6ee0d6b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/automd.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ export interface AutomdResult extends TransformResult {
1010
output: string;
1111
}
1212

13-
export async function automd(
14-
_config: Config = {},
15-
): Promise<{ results: AutomdResult[]; _config: ResolvedConfig; time: number }> {
13+
export async function automd(_config: Config = {}): Promise<{
14+
results: AutomdResult[];
15+
time: number;
16+
config: ResolvedConfig;
17+
unwatch?: () => void | Promise<void>;
18+
}> {
1619
const start = performance.now();
1720
const config = await loadConfig(_config.dir, _config);
1821

@@ -39,16 +42,18 @@ export async function automd(
3942
inputFiles.map((i) => _automd(i, config, multiFiles, cache)),
4043
);
4144

45+
let unwatch;
4246
if (config.watch) {
43-
await _watch(inputFiles, config, multiFiles, cache);
47+
unwatch = await _watch(inputFiles, config, multiFiles, cache);
4448
}
4549

4650
const time = performance.now() - start;
4751

4852
return {
49-
_config: config,
5053
time,
5154
results,
55+
config,
56+
unwatch,
5257
};
5358
}
5459

@@ -119,4 +124,6 @@ async function _watch(
119124
process.on("SIGINT", () => {
120125
subscription.unsubscribe();
121126
});
127+
128+
return subscription.unsubscribe;
122129
}

0 commit comments

Comments
 (0)