UNPKG

760 BPlain TextView Raw
1#!/usr/bin/env node
2import Args from 'vamtiger-argv/build/main';
3import getDirectoryContent from 'vamtiger-get-directory-content';
4import createProject from '.';
5
6const workingDirectory = process.cwd();
7const args = new Args();
8
9main().catch(handleError);
10
11async 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
25function handleError(error: Error) {
26 console.error(error);
27
28 process.exit();
29}
30
31const enum ErrorMessage {
32 alreadyCreated = 'This project has already been created'
33};
\No newline at end of file