Skip to content

Commit

Permalink
JestProcess.stop returns promise to support more sequential flow
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinczenko committed Jan 30, 2018
1 parent 6714a90 commit 5727128
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/JestExt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ export class JestExt {
if (response) {
this.jestProcess.runJestWithUpdateForSnapshots(() => {
if (this.pluginSettings.restartJestOnSnapshotUpdate) {
this.jestProcessManager.stopAll()
this.startProcess()
this.jestProcessManager.stopJestProcess(this.jestProcess).then(() => {
this.startProcess()
})
vscode.window.showInformationMessage('Updated Snapshots and restarted Jest.')
} else {
vscode.window.showInformationMessage('Updated Snapshots. It will show in your next test run.')
Expand Down
7 changes: 7 additions & 0 deletions src/JestProcessManagement/JestProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class JestProcess {
private projectWorkspace: ProjectWorkspace
private onExitCallback: Function
private jestSupportEvents: Map<string, (...args: any[]) => void>
private resolve: Function
private keepAliveCounter: number
public keepAlive: boolean
public watchMode: boolean
Expand All @@ -28,6 +29,9 @@ export class JestProcess {
this.startRunner()
} else if (this.onExitCallback) {
this.onExitCallback(this)
if (this.stopRequested) {
this.resolve()
}
}
}
})
Expand Down Expand Up @@ -72,6 +76,9 @@ export class JestProcess {
this.keepAliveCounter = 1
this.jestSupportEvents.clear()
this.runner.closeProcess()
return new Promise(resolve => {
this.resolve = resolve
})
}

public runJestWithUpdateForSnapshots(callback) {
Expand Down
2 changes: 1 addition & 1 deletion src/JestProcessManagement/JestProcessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class JestProcessManager {

public stopJestProcess(jestProcess) {
this.removeJestProcessReference(jestProcess)
jestProcess.stop()
return jestProcess.stop()
}

public get numberOfProcesses() {
Expand Down

0 comments on commit 5727128

Please sign in to comment.