aboutsummaryrefslogtreecommitdiffstats
path: root/bin/console.ts
diff options
context:
space:
mode:
Diffstat (limited to 'bin/console.ts')
-rw-r--r--bin/console.ts30
1 files changed, 15 insertions, 15 deletions
diff --git a/bin/console.ts b/bin/console.ts
index 4b102ee..c92f633 100644
--- a/bin/console.ts
+++ b/bin/console.ts
@@ -11,14 +11,14 @@
11| 11|
12*/ 12*/
13 13
14import 'reflect-metadata' 14import 'reflect-metadata';
15import { Ignitor, prettyPrintError } from '@adonisjs/core' 15import { Ignitor, prettyPrintError } from '@adonisjs/core';
16 16
17/** 17/**
18 * URL to the application root. AdonisJS need it to resolve 18 * URL to the application root. AdonisJS need it to resolve
19 * paths to file and directories for scaffolding commands 19 * paths to file and directories for scaffolding commands
20 */ 20 */
21const APP_ROOT = new URL('../', import.meta.url) 21const APP_ROOT = new URL('../', import.meta.url);
22 22
23/** 23/**
24 * The importer is used to import files in context of the 24 * The importer is used to import files in context of the
@@ -26,22 +26,22 @@ const APP_ROOT = new URL('../', import.meta.url)
26 */ 26 */
27const IMPORTER = (filePath: string) => { 27const IMPORTER = (filePath: string) => {
28 if (filePath.startsWith('./') || filePath.startsWith('../')) { 28 if (filePath.startsWith('./') || filePath.startsWith('../')) {
29 return import(new URL(filePath, APP_ROOT).href) 29 return import(new URL(filePath, APP_ROOT).href);
30 } 30 }
31 return import(filePath) 31 return import(filePath);
32} 32};
33 33
34new Ignitor(APP_ROOT, { importer: IMPORTER }) 34new Ignitor(APP_ROOT, { importer: IMPORTER })
35 .tap((app) => { 35 .tap(app => {
36 app.booting(async () => { 36 app.booting(async () => {
37 await import('#start/env') 37 await import('#start/env');
38 }) 38 });
39 app.listen('SIGTERM', () => app.terminate()) 39 app.listen('SIGTERM', () => app.terminate());
40 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate()) 40 app.listenIf(app.managedByPm2, 'SIGINT', () => app.terminate());
41 }) 41 })
42 .ace() 42 .ace()
43 .handle(process.argv.splice(2)) 43 .handle(process.argv.splice(2))
44 .catch((error) => { 44 .catch(error => {
45 process.exitCode = 1 45 process.exitCode = 1;
46 prettyPrintError(error) 46 prettyPrintError(error);
47 }) 47 });