forked from jed/config-leaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (35 loc) · 1002 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var crypto = require("crypto");
var fs = require("fs");
var prompt = require("prompt");
var path = require("path");
module.exports = function(fn) {
var from = path.join(process.cwd(), process.argv[2]);
var to = path.join(process.cwd(), process.argv[3]);
prompt.start();
var schema = {
description: "Enter the config password (" + path.basename(to) + "):\n",
name: "password",
type: "string",
hidden: true,
replace: "*",
required: false
};
var getSchema = [];
if (!process.env.CONFIG_LEAF_PASSWORD) {
getSchema.push(schema);
}
prompt.get(getSchema, function (err, result) {
if (err) {
console.log(err);
} else {
from = fs.createReadStream(from);
to = fs.createWriteStream(to);
fn = fn("cast5-cbc", result.password || process.env.CONFIG_LEAF_PASSWORD);
from.pipe(fn).pipe(to);
from.on("end", function () {
console.log("done");
prompt.stop();
});
}
});
};