-
Notifications
You must be signed in to change notification settings - Fork 3
/
helpers.js
53 lines (42 loc) · 1.13 KB
/
helpers.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const os = require('os')
const yargs = require('yargs')
const del = require('del')
const { yellow, bold, green, grey } = require('chalk')
const logger = {
info: console.log,
success: msg => console.log(green(msg))
}
// returns all args as an yargs object
const args = yargs(process.argv).argv
const objToEnvStr = obj =>
Object.entries(obj)
.reduce((acc, [key, val]) => acc + `${key}=${val} `, '')
.trimRight()
const clearBuildFolder = path => {
logger.info('clearing build folder')
return del(path, { force: true })
}
const defaultMeteorBuildDir = `${os.homedir()}/.meteor-hero/builds`
const meteorBuildDir = args['b'] || defaultMeteorBuildDir
function explain (explanation) {
console.log(`
${yellow(`🚨 Something happened that probably shouldn't have.`)}
${grey(`Details:`)}
${explanation}
${`Run ${bold(
`meteor-hero -h`
)} to see the full help menu and list of options`}
${grey(
`If all else fails go to https://github.com/jkrup/meteor-hero/issues and post an issue there.`
)}
`)
process.exit(1)
}
module.exports = {
args,
clearBuildFolder,
explain,
logger,
meteorBuildDir,
objToEnvStr
}