-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·28 lines (26 loc) · 809 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·28 lines (26 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const fs = require('fs');
const chalk = require('chalk');
const moduleName = process.argv[2];
const isPackage = process.argv.includes('--package') || process.argv.includes('-p');
const isGlobal = process.argv.includes('--global') || process.argv.includes('-g');
if (!moduleName) {
console.error(chalk.red.bold('Must supply a name for this module. Ex: $ dynamod my-module'));
process.exit(1);
}
const {
Context,
scaffold,
} = require('./utils')
const context = new Context(moduleName, isPackage, isGlobal);
const filesToBuild = [
'module',
'service',
'constants'
];
if (fs.existsSync(`./${context.camel}`)){
console.error(chalk.red.bold(`Directory with name "${context.camel}" already exists. Aborting.`));
process.exit(1);
} else {
scaffold(context, filesToBuild);
}