-
Notifications
You must be signed in to change notification settings - Fork 17
/
prepare.js
33 lines (28 loc) · 965 Bytes
/
prepare.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
var fs = require("fs");
var path = require("path");
module.exports = function prepare(config) {
if (!fs.existsSync("bin")) {
fs.mkdirSync("bin");
}
var binstubTemplate = fs.readFileSync(path.join(__dirname, "binstub.js.mustache")).toString();
config.binaries.forEach(function(bin) {
var binPath = path.join("bin", bin);
var content = binstubTemplate.replace(/{{ binName }}/g, JSON.stringify(bin));
fs.writeFileSync(binPath, content);
fs.chmodSync(binPath, "755");
});
// verifyAllBinsExist(packageInfo.bin);
return new Promise(function(resolve) { resolve(); });
};
// function verifyAllBinsExist(binInfo) {
// Object.keys(binInfo).forEach(function(name) {
// var bin = binInfo[name];
// if (!fs.existsSync(bin)) {
// throw new Error(
// "bin listed in package.json does not exist: " +
// bin +
// "\n\nTODO: Maybe you forgot to include it in ..."
// );
// }
// });
// }