-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add result export and update README (#171)
* runresult-proxy * update README * Update index.ts
- Loading branch information
Showing
5 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import type Generator from 'yeoman-generator'; | ||
import type RunContext from './run-context.js'; | ||
import type RunResult from './run-result.js'; | ||
|
||
class TestContext { | ||
runResult?: RunResult; | ||
private runContext?: RunContext<any>; | ||
|
||
startNewContext(runContext: RunContext<any>) { | ||
this.runContext?.cleanupTemporaryDir(); | ||
this.runContext = runContext; | ||
this.runResult = undefined; | ||
} | ||
} | ||
|
||
export default new TestContext(); | ||
const testContext = new TestContext(); | ||
|
||
export default testContext; | ||
|
||
const handler2 = { | ||
get(_target, prop, receiver) { | ||
if (testContext.runResult === undefined) { | ||
throw new Error('Last result is missing.'); | ||
} | ||
|
||
return Reflect.get(testContext.runResult, prop, receiver); | ||
}, | ||
}; | ||
|
||
/** | ||
* Provides a proxy for last executed context result. | ||
*/ | ||
export const result: RunResult = new Proxy({}, handler2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters