-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (33 loc) · 1.42 KB
/
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
43
// License at bottom of file, because who wants to start by reading a license?
const fs = require('fs');
let startCb = () => {};
const whitelist = process.env.IRONMANJS_WHITELIST?.split(',') || [];
whitelist.push('ironmanjs');
const whitelistMap = whitelist.reduce((prev, cur) => { prev[cur] = true; return prev; }, {});
fs.readFile('package.json', (err, data) => {
if (err) {
if (!err.code === 'ENOENT') throw new Error('IronmanJS - Cannot read package.json');
return;
}
const dependencies = Object.keys(JSON.parse(data.toString())['dependencies']);
const extraDependencies = dependencies.filter(dep => !whitelistMap[dep])
if (extraDependencies.length !== 0) {
console.log(
'Uninstall these packages to get the ironman JS experience: "' +
extraDependencies.join('", "') + '"'
);
throw new Error('IronmanJS - Too Many Packages');
}
startCb();
});
module.exports = (cb) => {
startCb = cb;
}
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <miningape@gmail.com> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Kyle Craig Johnson
* ----------------------------------------------------------------------------
*/