Skip to content

Commit

Permalink
feat: 常用及通用的功能传递给 脚手架|builder|deploy 及插件使用
Browse files Browse the repository at this point in the history
  • Loading branch information
WnineM committed Jan 2, 2019
1 parent a482e78 commit 0845f32
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
14 changes: 14 additions & 0 deletions lib/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { camelizeKeys } = require('humps');
const logger = require('./logger');
const Command = require('./command');
const utils = require('../utils');
const Loading = require('../utils');
const pkg = require('../../package.json');
const sep = pathFn.sep;

Expand Down Expand Up @@ -47,6 +48,19 @@ class Feflow {
this.args = camelizeKeys(args);

this.cmd = new Command();

// 常用及通用的功能传递给 脚手架|builder|deploy 及插件使用
this.coreFn = {
// 一系列常用库集合 如chalk inquirer opn 等等
chalk: chalk,
// 执行异步操作可调用统一输出产品 feflow 心智
Loading: Loading,
// 实用方法套件插件也使用
log: this.log
// 数据埋点方法函数..
// 消息通知 notice 等封装函数..
};

}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/build/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Builder {
}

runBuild(cmd) {
const self = this;
const { log, pluginDir, baseDir } = this.ctx;
const type = Config.getBuilderType();
const path = pathFn.join(pluginDir, type);
Expand All @@ -27,7 +28,7 @@ class Builder {
if (!result.code) {
loading.success();
log.info(`${type} 构建器安装完成, 即将执行构建命令...`);
require(path)(cmd);
require(path)(cmd, self.ctx);
} else {
const err = `${type} 构建器安装失败,失败码为${result.code},错误日志为${result.data}`;
loading.fail(err);
Expand All @@ -36,7 +37,7 @@ class Builder {
});
} else {
return this.checkUpdate().then(() => {
require(path)(cmd);
require(path)(cmd, self.ctx);
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/deploy/deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Deployer {
}

runBuild(cmd) {
const self = this;
const { log, pluginDir, baseDir } = this.ctx;
const type = Config.getDeployerType();
const path = pathFn.join(pluginDir, type);
Expand All @@ -27,7 +28,7 @@ class Deployer {
if (!result.code) {
loading.success();
log.info(`${type} 部署器安装完成, 即将执行构建命令...`);
require(path)(cmd);
require(path)(cmd, self.ctx);
} else {
const err = `${type} 部署器安装失败,失败码为${result.code},错误日志为${result.data}`;
loading.fail(err);
Expand All @@ -36,7 +37,7 @@ class Deployer {
});
} else {
return this.checkUpdate().then(() => {
require(path)(cmd);
require(path)(cmd, self.ctx);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/generator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Generator {
}

yeomanEnv.register(require.resolve(path), name);
yeomanEnv.run(name, this.args, err => {
yeomanEnv.run(name, ctx, err => {
});
}

Expand Down

0 comments on commit 0845f32

Please sign in to comment.