-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should support windows and Node.js 14 (#223)
use fork instead of runscript
- Loading branch information
Showing
11 changed files
with
170 additions
and
69 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
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,30 @@ | ||
import { debuglog } from 'node:util'; | ||
import { | ||
Inject, ApplicationLifecycle, LifecycleHook, LifecycleHookUnit, Program, | ||
ArtusCliError, | ||
} from '@artus-cli/artus-cli'; | ||
|
||
const debug = debuglog('egg-bin:midddleware:handle_error'); | ||
|
||
@LifecycleHookUnit() | ||
export default class implements ApplicationLifecycle { | ||
@Inject() | ||
private readonly program: Program; | ||
|
||
@LifecycleHook() | ||
async configDidLoad() { | ||
this.program.use(async (_, next) => { | ||
debug('enter next'); | ||
try { | ||
await next(); | ||
debug('after next'); | ||
} catch (err: any) { | ||
debug('next error: %o', err); | ||
// let artus cli to handle it | ||
if (err instanceof ArtusCliError) throw err; | ||
console.error(err); | ||
process.exit(typeof err.code === 'number' ? err.code : 1); | ||
} | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.