|
7 | 7 | * file that was distributed with this source code. |
8 | 8 | */ |
9 | 9 |
|
10 | | -import { ensureDirSync } from 'fs-extra' |
11 | 10 | import { bgRed, red } from 'kleur' |
| 11 | +import { ensureDirSync } from 'fs-extra' |
12 | 12 | import { isAbsolute, join, basename } from 'path' |
13 | 13 | import { Application } from '@poppinss/application' |
14 | 14 | import { executeInstructions, isEmptyDir } from '@adonisjs/sink' |
@@ -38,60 +38,67 @@ export async function runTasks (projectRoot: string) { |
38 | 38 | */ |
39 | 39 | const isEmpty = isEmptyDir(absPath) |
40 | 40 | if (!isEmpty) { |
41 | | - console.log(bgRed(`Error`)) |
42 | | - console.log(red(`- Cannot overwrite existing contents in {${projectRoot}} directory`)) |
43 | | - console.log(red(`- Make sure that {${projectRoot}} directory is empty`)) |
44 | | - return |
| 41 | + console.error(bgRed(`Error`)) |
| 42 | + console.error(red(`- Cannot overwrite existing contents in {${projectRoot}} directory`)) |
| 43 | + console.error(red(`- Make sure that {${projectRoot}} directory is empty`)) |
| 44 | + process.exit(1) |
45 | 45 | } |
46 | 46 |
|
47 | | - /** |
48 | | - * Pulling the project name from the project root path |
49 | | - */ |
50 | | - const projectName = basename(absPath) |
| 47 | + try { |
| 48 | + /** |
| 49 | + * Pulling the project name from the project root path |
| 50 | + */ |
| 51 | + const projectName = basename(absPath) |
51 | 52 |
|
52 | | - /** |
53 | | - * Creating the `.adonisrc.json` file |
54 | | - */ |
55 | | - createRcFile(absPath, application) |
| 53 | + /** |
| 54 | + * Creating the `.adonisrc.json` file |
| 55 | + */ |
| 56 | + createRcFile(absPath, application) |
56 | 57 |
|
57 | | - /** |
58 | | - * Creating the `.env` file |
59 | | - */ |
60 | | - createEnvFile(absPath) |
| 58 | + /** |
| 59 | + * Creating the `.env` file |
| 60 | + */ |
| 61 | + createEnvFile(absPath) |
61 | 62 |
|
62 | | - /** |
63 | | - * Creating the `.gitignore` file |
64 | | - */ |
65 | | - createGitIgnore(absPath) |
| 63 | + /** |
| 64 | + * Creating the `.gitignore` file |
| 65 | + */ |
| 66 | + createGitIgnore(absPath) |
66 | 67 |
|
67 | | - /** |
68 | | - * Creating the `.editorconfig` file |
69 | | - */ |
70 | | - createEditorConfig(absPath) |
| 68 | + /** |
| 69 | + * Creating the `.editorconfig` file |
| 70 | + */ |
| 71 | + createEditorConfig(absPath) |
71 | 72 |
|
72 | | - /** |
73 | | - * Creating `tsconfig.json` file |
74 | | - */ |
75 | | - createTsConfig(absPath) |
| 73 | + /** |
| 74 | + * Creating `tsconfig.json` file |
| 75 | + */ |
| 76 | + createTsConfig(absPath) |
76 | 77 |
|
77 | | - /** |
78 | | - * Creating `tslint.json` file |
79 | | - */ |
80 | | - createTsLint(absPath) |
| 78 | + /** |
| 79 | + * Creating `tslint.json` file |
| 80 | + */ |
| 81 | + createTsLint(absPath) |
81 | 82 |
|
82 | | - /** |
83 | | - * Creating `package.json` file and install required dependencies |
84 | | - */ |
85 | | - createPackageFile(absPath, projectName) |
| 83 | + /** |
| 84 | + * Creating `package.json` file and install required dependencies |
| 85 | + */ |
| 86 | + createPackageFile(absPath, projectName) |
86 | 87 |
|
87 | | - /** |
88 | | - * Copy application templates |
89 | | - */ |
90 | | - copyTemplates(absPath) |
| 88 | + /** |
| 89 | + * Copy application templates |
| 90 | + */ |
| 91 | + copyTemplates(absPath) |
91 | 92 |
|
92 | | - /** |
93 | | - * Executing instructions from `@adonisjs/core`. Please check the package |
94 | | - * repo to see the actions executed there |
95 | | - */ |
96 | | - await executeInstructions('@adonisjs/core', absPath, application) |
| 93 | + /** |
| 94 | + * Executing instructions from `@adonisjs/core` and `@adonisjs/bodyparser`. |
| 95 | + * Please check the packages repos to see the actions executed there. |
| 96 | + */ |
| 97 | + await executeInstructions('@adonisjs/core', absPath, application) |
| 98 | + await executeInstructions('@adonisjs/bodyparser', absPath, application) |
| 99 | + process.exit(0) |
| 100 | + } catch (error) { |
| 101 | + console.error(error) |
| 102 | + process.exit(1) |
| 103 | + } |
97 | 104 | } |
0 commit comments