Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Commit 6c48b96

Browse files
committed
Add env var support for config leaf
1 parent 787c315 commit 6c48b96

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Diff for: index.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,30 @@ module.exports = function(fn) {
88
var to = path.join(process.cwd(), process.argv[3]);
99

1010
prompt.start();
11-
12-
prompt.get([
13-
{
14-
description: "Enter the config password (" + path.basename(to) + "):\n",
15-
name: "password",
16-
type: "string",
17-
hidden: true,
18-
replace: "*",
19-
required: true
20-
}
21-
], function (err, result) {
11+
12+
var schema = {
13+
description: "Enter the config password (" + path.basename(to) + "):\n",
14+
name: "password",
15+
type: "string",
16+
hidden: true,
17+
replace: "*",
18+
required: false
19+
};
20+
21+
var getSchema = [];
22+
23+
if (!process.env.CONFIG_LEAF_PASSWORD) {
24+
getSchema.push(schema);
25+
}
26+
27+
prompt.get(getSchema, function (err, result) {
2228
if (err) {
2329
console.log(err);
2430
} else {
2531
from = fs.createReadStream(from);
2632
to = fs.createWriteStream(to);
27-
fn = fn("cast5-cbc", result.password);
28-
33+
fn = fn("cast5-cbc", result.password || process.env.CONFIG_LEAF_PASSWORD);
34+
2935
from.pipe(fn).pipe(to);
3036
from.on("end", function () {
3137
console.log("done");

0 commit comments

Comments
 (0)