Skip to content

Commit ff4585b

Browse files
committed
allow config file to export a function
pass --env to config function
1 parent b31a811 commit ff4585b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

bin/config-optimist.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module.exports = function(optimist) {
55

66
.string("config").describe("config")
77

8+
.string("env").describe("env", "Enviroment passed to the config, when it is a function")
9+
810
.string("context").describe("context")
911

1012
.string("entry").describe("entry")

bin/convert-argv.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ module.exports = function(optimist, argv, convertOptions) {
3636
configFileLoaded = true;
3737
}
3838
}
39+
40+
if(typeof options === "function") {
41+
options = options(argv.env, argv);
42+
}
43+
3944
if(typeof options !== "object" || options === null) {
4045
console.log("Config did not export a object.");
4146
process.exit(-1);

0 commit comments

Comments
 (0)