Skip to content

Commit d1e7fc3

Browse files
committed
reset watchers on reset
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent b6501e0 commit d1e7fc3

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,8 @@ Adds a review page for viewing tutorial content. The review page should be espec
248248
- Supports commands on reset
249249
- Supports running vscode commands anywhere that command line commands can be run
250250
- Admin mode to allow creators to jump between tutorial levels/steps during development
251+
252+
### [0.13.1]
253+
254+
- Add logo
255+
- Fix issue with watcher tests running on reset

src/services/hooks/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import * as T from 'typings'
21
import * as TT from 'typings/tutorial'
32
import * as git from '../git'
43
import loadCommits from './utils/loadCommits'
5-
import loadWatchers from './utils/loadWatchers'
4+
import { loadWatchers, resetWatchers } from './utils/watchers'
65
import openFiles from './utils/openFiles'
76
import runCommands from './utils/runCommands'
87
import runVSCodeCommands from './utils/runVSCodeCommands'
@@ -39,6 +38,7 @@ export const onSolutionEnter = async (actions: TT.StepActions): Promise<void> =>
3938
}
4039

4140
export const onReset = async (actions: TT.StepActions): Promise<void> => {
41+
await resetWatchers()
4242
await runCommands(actions?.commands)
4343
await runVSCodeCommands(actions?.vscodeCommands)
4444
}

src/services/hooks/utils/loadWatchers.ts src/services/hooks/utils/watchers.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const disposeWatcher = (watcher: string) => {
1414
delete watcherObject[watcher]
1515
}
1616

17-
const loadWatchers = (watchers: string[] = []): void => {
17+
export const loadWatchers = (watchers: string[] = []): void => {
1818
if (!watchers.length) {
1919
// remove all watchers
2020
for (const watcher of Object.keys(watcherObject)) {
@@ -55,4 +55,8 @@ const loadWatchers = (watchers: string[] = []): void => {
5555
}
5656
}
5757

58-
export default loadWatchers
58+
export const resetWatchers = (): void => {
59+
for (const watcher of Object.keys(watcherObject)) {
60+
disposeWatcher(watcher)
61+
}
62+
}

0 commit comments

Comments
 (0)