Skip to content

Commit 9707ab1

Browse files
committed
added official module check
1 parent 733d31b commit 9707ab1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
"license": "Apache-2.0",
1111
"author": "James Chong",
12+
"officialModules":["basic","open","zip","beeper","notifier","figlet","file","csv","date","hogan","downloading"],
1213
"repository": {
1314
"type": "git",
1415
"url": "https://github.com/wei3hua2/rpscript.git"
@@ -28,7 +29,7 @@
2829
"cli-table": "^0.3.1",
2930
"commander": "^2.15.1",
3031
"dateformat": "^3.0.3",
31-
"rpscript-parser": "^0.5.31",
32+
"rpscript-parser": "^0.5.32",
3233
"winston": "^3.0.0"
3334
},
3435
"devDependencies": {

src/commands/modules.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as R from '../../lib/ramda.min';
44
import {EventEmitter} from 'events';
55
import {Logger} from '../core/logger';
66

7+
var pjson = require('../../package.json');
8+
79
export class ModuleCommand {
810

911
modMgr:ModuleMgr;
@@ -16,9 +18,15 @@ export class ModuleCommand {
1618
}
1719

1820
async install(allowExternalModule:boolean,modName:string[]) :Promise<void>{
21+
1922
for(var i=0;i<modName.length;i++){
20-
this.logger.info('installing module '+modName[i]+'...');
21-
await this.modMgr.installModule(modName[i],allowExternalModule);
23+
if(!allowExternalModule && !R.contains(modName[i],pjson.officialModules))
24+
this.logger.error(modName[i]+' is not part of the official package. Fail to install.');
25+
else {
26+
this.logger.info('installing module '+modName[i]+'...');
27+
await this.modMgr.installModule(modName[i],allowExternalModule);
28+
}
29+
2230
}
2331
}
2432
async remove(modName:string[]) :Promise<any>{

0 commit comments

Comments
 (0)