-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeature-deployer-bin.js
More file actions
executable file
·44 lines (32 loc) · 1.21 KB
/
feature-deployer-bin.js
File metadata and controls
executable file
·44 lines (32 loc) · 1.21 KB
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
40
41
42
43
44
#!/usr/bin/env node
const chalk = require('chalk')
const logger = require('./Infra/logger')
const featureDeployer = require('./Infra/feature-deployer')
function logCommand (command, index, array) {
const color = index === array.length - 1 ? this.errorColor : 'grey'
logger.info(chalk[color](command))
}
function logExecutedCommands ({ commands, error }) {
if (!commands || !commands.length) return
logger.info(chalk.white('\nExecuted Plan:\n'))
commands.forEach(logCommand, { errorColor: error ? 'red' : 'grey' })
logger.info('')
}
async function execute () {
try {
const commands = await featureDeployer(process.argv)
logExecutedCommands({ commands, error: false })
logger.info(chalk.green.bold('✨ Command execute successfully!!!'))
} catch (error) {
logExecutedCommands({ commands: featureDeployer.commands, error: true })
logger.info(chalk.red(`ErrorMessage: ${chalk.red.bold(error.message)}`))
logger.info('')
logger.info(chalk.red('❌ ❌ 😭 😭 Unfortunately it did not work 😭 😭 ❌ ❌'))
logger.verbose(chalk.red(error.stack))
process.exit(1)
}
}
execute()
process.on('unhandledRejection', function (reason, p) {
logger.error(chalk.red(reason))
})