1 | const path = require('path')
|
2 | const chalk = require('chalk')
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | module.exports = ({
|
9 | config,
|
10 | type,
|
11 | port
|
12 | }) => {
|
13 | let modified = false
|
14 |
|
15 | if (typeof config === 'string') {
|
16 | config = path.resolve(config)
|
17 | process.env.KOOT_BUILD_CONFIG_PATHNAME = config
|
18 | console.log(
|
19 | chalk.green('√ ')
|
20 | + chalk.yellowBright('[koot] ')
|
21 | + `set env ` + chalk.green('KOOT_BUILD_CONFIG_PATHNAME')
|
22 | + `\n -> `
|
23 | + config
|
24 | )
|
25 | modified = true
|
26 | }
|
27 |
|
28 | if (typeof type === 'string') {
|
29 | process.env.KOOT_PROJECT_TYPE = type
|
30 | console.log(
|
31 | chalk.green('√ ')
|
32 | + chalk.yellowBright('[koot] ')
|
33 | + `set env ` + chalk.green('KOOT_PROJECT_TYPE')
|
34 | + `\n -> `
|
35 | + type
|
36 | )
|
37 | modified = true
|
38 | }
|
39 |
|
40 | if (typeof port === 'string' || typeof port === 'number') {
|
41 | process.env.SERVER_PORT = port
|
42 | console.log(
|
43 | chalk.green('√ ')
|
44 | + chalk.yellowBright('[koot] ')
|
45 | + `set env ` + chalk.green('SERVER_PORT')
|
46 | + `\n -> `
|
47 | + port
|
48 | )
|
49 | modified = true
|
50 | }
|
51 |
|
52 | if (modified) console.log(' ')
|
53 |
|
54 | return {
|
55 | config, type, port
|
56 | }
|
57 | }
|