/
restrict.js
58 lines (39 loc) · 1.1 KB
/
restrict.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
module.exports = {
friendlyName: 'Restrict access',
description: 'Restrict access to a package published on NPM.',
inputs: {
packageName: {
friendlyName: 'Package name',
description: 'The name of the NPM package to retrict access to.',
example: '@mattmueller/cheerio',
required: true
}
},
exits: {
unscopedPackage: {
description: 'You can\'t change the access level of an unscoped package (e.g. "lodash" is unscoped, whereas "@jdalton/lodash" is scoped.)'
},
success: {
description: 'Done.',
}
},
fn: function (inputs,exits) {
var Proc = require('machinepack-process');
Proc.spawn({
command: 'npm access restricted '+inputs.packageName
}).exec({
error: function (err){
try {
if (err.message.match(/Sorry, you can\'t change the access level of unscoped packages/i)) {
return exits.unscopedPackage();
}
}
catch (_e){}
return exits.error(err);
},
success: function (bufferedOutput){
return exits.success();
}
});
},
};