|
1 | 1 | import * as fs from 'fs-extra'; |
2 | | -import { startsWith, get, merge, replace } from 'lodash'; |
| 2 | +import { startsWith, get, merge, replace, isNil } from 'lodash'; |
3 | 3 | import { getCurrentPath } from './utils'; |
4 | 4 | import path from 'path'; |
5 | 5 | import yaml from 'js-yaml'; |
@@ -44,11 +44,10 @@ export default class Parse { |
44 | 44 | const { variableName, type, funName, funVariable } = variableObj; |
45 | 45 | const result = ''; |
46 | 46 | if (type === 'Literal') { |
47 | | - return ( |
48 | | - this.globalJsonKeyMap[variableName] || |
49 | | - this.globalJsonKeyMap[`services.${variableName}`] || |
50 | | - '${' + variableName + '}' |
51 | | - ); |
| 47 | + if (!isNil(this.globalJsonKeyMap[variableName])) return this.globalJsonKeyMap[variableName]; |
| 48 | + if (!isNil(this.globalJsonKeyMap[`services.${variableName}`])) |
| 49 | + return this.globalJsonKeyMap[`services.${variableName}`]; |
| 50 | + return '${' + variableName + '}'; |
52 | 51 | } |
53 | 52 | if (type === 'Fun' && (funName === 'Env' || funName === 'env')) { |
54 | 53 | return process.env[funVariable]; |
@@ -125,7 +124,7 @@ export default class Parse { |
125 | 124 | let realValue = startsWith(matchResult, 'env.') |
126 | 125 | ? get(process, matchResult) |
127 | 126 | : this.findVariableValue(variableObj); |
128 | | - if (realValue) { |
| 127 | + if (!isNil(realValue)) { |
129 | 128 | tmp = |
130 | 129 | Object.prototype.toString.call(realValue) === '[object String]' |
131 | 130 | ? replace(tmp, iterator, realValue) |
|
0 commit comments