1 | #!/usr/bin/env node
|
2 | import Args from 'vamtiger-argv/build/main';
|
3 | import getDirectoryContent from 'vamtiger-get-directory-content';
|
4 | import createProject from '.';
|
5 |
|
6 | const workingDirectory = process.cwd();
|
7 | const args = new Args();
|
8 |
|
9 | main().catch(handleError);
|
10 |
|
11 | async function main() {
|
12 | const directoryContent = await getDirectoryContent(workingDirectory);
|
13 | const ignore = directoryContent.includes('package.json');
|
14 |
|
15 | if (ignore) {
|
16 | throw new Error(ErrorMessage.alreadyCreated);
|
17 | }
|
18 |
|
19 | await createProject();
|
20 |
|
21 | if (!args.has('keepAlive'))
|
22 | process.exit();
|
23 | }
|
24 |
|
25 | function handleError(error: Error) {
|
26 | console.error(error);
|
27 |
|
28 | process.exit();
|
29 | }
|
30 |
|
31 | const enum ErrorMessage {
|
32 | alreadyCreated = 'This project has already been created'
|
33 | }; |
\ | No newline at end of file |