-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
executable file
·39 lines (30 loc) · 1.09 KB
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
const chalk = require('chalk')
const emoji = require('node-emoji')
const Raven = require('raven')
const checkFolderExists = require('./utils/checkFolderExists')
const R = require('ramda')
// "awesomeCreateApp.js" runs some code, so Raven must be already installed
Raven.config('https://0a378170ac02430383fad7bfa98cb2fa:[email protected]/227839').install()
const awesomeCreateApp = require('./awesomeCreateApp')
const defaultErrorMessage = msg =>
`${emoji.get('boom')} ${chalk.red('Error')} ${emoji.get('boom')}
${msg}`
const missingAppNameError = defaultErrorMessage(chalk.red('App name must be provided'))
const folderExistsError = folderName => {
R.pipe(
defaultErrorMessage,
console.log
)(`${chalk.blue(folderName)} directory already exists`)
process.exit(1)
}
const argv = require('yargs')
.usage('$0 <appName>')
.demandCommand(1, missingAppNameError)
.help()
.version('0.0.1')
.argv
const folderName = argv._[0]
checkFolderExists(folderName)
.then(() => folderExistsError(folderName))
.catch(() => awesomeCreateApp(folderName))