-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking: refactory of all main/worker hooks
- Loading branch information
1 parent
dcad916
commit b6e9143
Showing
13 changed files
with
180 additions
and
138 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const beforeRun = 'BeforeRun'; | ||
const afterRun = 'AfterRun'; | ||
|
||
export const worker = [ | ||
'onReady', | ||
`code${beforeRun}`, | ||
`code${beforeRun}Async`, | ||
`code${afterRun}`, | ||
`code${afterRun}Async`, | ||
]; | ||
|
||
export const main = [ | ||
...worker, | ||
'onWorker', | ||
`on${beforeRun}`, | ||
`on${beforeRun}Async`, | ||
`on${afterRun}`, | ||
`on${afterRun}Async`, | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { dedent } from '../utils.js'; | ||
import { worker } from '../hooks.js'; | ||
|
||
// REQUIRES INTEGRATION TEST | ||
/* c8 ignore start */ | ||
export default class Hook { | ||
constructor(interpreter, { hooks }) { | ||
this.interpreter = interpreter; | ||
this.onWorker = hooks?.main?.onWorker; | ||
for (const key of worker) | ||
this[key] = hooks?.worker?.[key]; | ||
} | ||
toJSON() { | ||
const hooks = {}; | ||
// exclude `onReady` callback | ||
for (const key of worker.slice(1)) { | ||
if (this[key]) hooks[key] = dedent(this[key]()); | ||
} | ||
return hooks; | ||
} | ||
} | ||
/* c8 ignore stop */ |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.