-
Notifications
You must be signed in to change notification settings - Fork 9
/
unienv.ts
52 lines (41 loc) · 865 Bytes
/
unienv.ts
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
import crossEnv from "cross-env"
import yargs from "yargs"
import { init } from "./index"
interface Parameter {
context?: string
verbose?: boolean
command: string[]
}
function getParameter(): Parameter {
const args = yargs
.option("context", {
alias: "c",
type: "string"
})
.option("verbose", {
alias: "v",
default: false,
type: "boolean"
}).argv
const { context, verbose, _ } = args
return {
context,
verbose,
command: _
}
}
function executeCommand(): void {
const args = getParameter()
if (args.context) {
process.env.ENV_CONTEXT = args.context
}
if (args.verbose) {
process.stderr.write("Load .env files...\n")
}
init()
if (args.verbose) {
process.stderr.write(`Execute "${args.command.join(" ")}"...\n`)
}
crossEnv(args.command)
}
executeCommand()