forked from jed/config-leaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 871 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
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();
prompt.get([
{
description: "Enter the config password (" + path.basename(to) + "):\n",
name: "password",
type: "string",
hidden: true,
replace: "*",
required: true
}
], function (err, result) {
if (err) {
console.log(err);
} else {
from = fs.createReadStream(from);
to = fs.createWriteStream(to);
fn = fn("cast5-cbc", result.password);
from.pipe(fn).pipe(to);
from.on("end", function () {
console.log("done");
prompt.stop();
});
}
});
};