Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
fix: dev pack clean (#141)
Browse files Browse the repository at this point in the history
* fix: dev pack clean

* fix: get function list
  • Loading branch information
echosoar committed Apr 23, 2020
1 parent c1e5d0a commit d2731c8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/faas-cli-command-core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export class CommandHookCore implements ICommandHooksCore {

debug(...args) {

const verbose = this.options.options.V || this.options.options.verbose;
const verbose = this.options.options.V || this.options.options.verbose || process.env.MIDWAY_FAAS_VERBOSE;
if (!verbose) {
return;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/faas-cli-plugin-invoke/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export class FaaSInvokePlugin extends BasePlugin {
const specFile = this.core.config.specFile.path;
// 只有当非首次调用时才会进行增量分析,其他情况均进行全量分析
if (existsSync(buildLockPath)) {
this.core.debug('buildLockPath', buildLockPath);
this.fileChanges = await compareFileChange(
[
specFile,
Expand Down Expand Up @@ -253,6 +254,7 @@ export class FaaSInvokePlugin extends BasePlugin {
// this.getAnaLysisCodeInfo();
// }
}
this.core.debug('fileChanges', this.fileChanges);
this.setLock(this.buildLockPath, LOCK_TYPE.WAITING);
}

Expand Down Expand Up @@ -419,6 +421,7 @@ export class FaaSInvokePlugin extends BasePlugin {
// ts模式 midway-core 会默认加载入口文件所在目录下的 src 目录里面的ts代码
// 因此通过软连接的形式将其与原代码目录进行绑定
const symlinkPath = resolve(this.buildDir, 'src');
this.core.debug('tsMode symlink', symlinkPath);
if (!existsSync(symlinkPath)) {
symlinkSync(this.codeAnalyzeResult.tsCodeRoot, resolve(this.buildDir, 'src'));
}
Expand Down
18 changes: 15 additions & 3 deletions packages/faas-cli-plugin-invoke/src/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export interface InvokeOptions {
export const getFunction = (getOptions) => {
return async (options: any) => {
const baseDir = options.functionDir || process.cwd();
const specFile = getSpecFile(baseDir);
const specFile = getOptions.specFile || getSpecFile(baseDir);
const core = new CommandHookCore({
config: {
servicePath: baseDir,
specFile
},
commands: ['invoke'],
service: loadSpec(baseDir, specFile),
service: getOptions.spec || loadSpec(baseDir, specFile),
provider: '',
options: {
function: options.functionName,
Expand Down Expand Up @@ -63,11 +63,23 @@ export interface IGetFuncList {
functionDir?: string; // 函数所在目录
sourceDir?: string; // 一体化目录结构下,函数的目录,比如 src/apis,这个影响到编译
verbose?: boolean; // 输出更多信息
[key: string]: any;
}
export async function getFuncList (options: IGetFuncList) {
const baseDir = options.functionDir || process.cwd();
const specFile = getSpecFile(baseDir);
const spec = loadSpec(baseDir, specFile);
// 如果spec中有functions,就不走代码分析
if (spec.functions) {
return spec.functions;
}
const invokeFun = getFunction({
stopLifecycle: 'invoke:analysisCode',
key: 'functions'
key: 'functions',
specFile,
spec
});
options.clean = false;
options.incremental = true;
return invokeFun(options);
}

0 comments on commit d2731c8

Please sign in to comment.