From bdcea1654bfa6934128d3b7f15d807315c920822 Mon Sep 17 00:00:00 2001 From: cpselvis Date: Thu, 14 Nov 2019 22:43:21 +0800 Subject: [PATCH] fix(core): client config through commands (#126) --- src/core/index.ts | 10 ++++++++++ src/core/native/config.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/core/index.ts b/src/core/index.ts index d1816a6b..23cc25d1 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -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); @@ -73,7 +75,15 @@ export default class Feflow { 'private': true }, null, 2)); } + + resolve(); + }); + } + + initPackageManager() { + const { root } = this; + return new Promise((resolve, reject) => { if (!this.config || !this.config.packageManager) { const isInstalled = (packageName: string) => { try { diff --git a/src/core/native/config.ts b/src/core/native/config.ts index 8bf32653..ae0209e9 100644 --- a/src/core/native/config.ts +++ b/src/core/native/config.ts @@ -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; }