forked from noi-techpark/odh-mentor-otp
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd6e681
commit 790170d
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
const fs = require('fs'); | ||
|
||
const ENV = process.env, | ||
infile = process.argv[2]; | ||
|
||
function tmpl(str, data) { | ||
//const tmplReg = /\$\{(.+?)\}/g | ||
const tmplReg = /\$\{([\w_\-]+)\}/g | ||
//const tmplReg = /\{ *([\w_\-]+) *\}/g | ||
|
||
return str.replace(tmplReg, function (str, key) { | ||
var value = data[key]; | ||
if (value === undefined) | ||
value = "${"+key+"}"; | ||
return value; | ||
}); | ||
} | ||
|
||
try { | ||
const configFile = fs.readFileSync(infile, 'utf8'); | ||
|
||
const configEnv = tmpl(configFile, ENV); | ||
|
||
console.log(configEnv); | ||
} | ||
catch (e) { | ||
console.log('Error: ',e.message); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters