-
Notifications
You must be signed in to change notification settings - Fork 534
/
index.js
64 lines (51 loc) · 1.33 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module.exports = snyk;
var cluster = require('cluster');
var snykConfig = require('./config');
function snyk(options) {
if (!options) {
options = {};
}
if (options.api) {
snykConfig.api = options.api;
}
if (options.id) {
snyk.id = options.id;
}
// FIXME add in pid + whether master + hostname + all these fields
snyk.config.isMaster = cluster.isMaster;
if (options.monitor && snyk.config.isMaster) {
if (!snyk.api) {
throw new Error('Snyk monitors require an authenticated account ' +
'and API token');
}
// hook();
require('./capture')();
}
return snyk;
}
snyk.id = snykConfig.id;
var apiToken = require('./api-token');
// make snyk.api *always* get the latest api token from the config store
Object.defineProperty(snyk, 'api', {
enumerable: true,
configurable: true,
get: function () {
return apiToken();
},
set: function (value) {
snykConfig.api = value;
},
});
snyk.modules = require('./modules');
snyk.test = require('./snyk-test');
snyk.monitor = require('./monitor');
snyk.bus = require('./bus');
snyk.policy = require('snyk-policy');
snyk.isRequired = true; // changed to false when loaded via cli
snyk.isolate = {
okay: function () {
return true;
},
};
// this is the user config, and not the internal config
snyk.config = require('./user-config');