Skip to content

Commit

Permalink
fix(core): client config through commands (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpselvis authored Nov 14, 2019
1 parent 6f179d1 commit bdcea16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ export default class Feflow {

async init(cmd: string) {
if (cmd === 'config') {
await this.initClient();
await this.loadNative();
} else {
await this.initClient();
await this.initPackageManager();
await this.checkUpdate();
await this.loadNative();
await loadPlugins(this);
Expand All @@ -73,7 +75,15 @@ export default class Feflow {
'private': true
}, null, 2));
}

resolve();
});
}

initPackageManager() {
const { root } = this;

return new Promise<any>((resolve, reject) => {
if (!this.config || !this.config.packageManager) {
const isInstalled = (packageName: string) => {
try {
Expand Down
3 changes: 3 additions & 0 deletions src/core/native/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ module.exports = (ctx: any) => {
switch (action) {
case 'get':
console.log(ctx.config[key]);
break;
case 'set':
config[key] = value;
safeDump(config, configPath);
break;
case 'list':
let str = '';
for (let prop in config) {
str += prop + ' = ' + config[prop] + '\n';
}
console.log(str.replace(/\s+$/g, ''));
break;
default:
return null;
}
Expand Down

0 comments on commit bdcea16

Please sign in to comment.