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

Commit

Permalink
fix: invoke bug (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
echosoar committed Apr 3, 2020
1 parent eb216d9 commit 7c2d000
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
8 changes: 0 additions & 8 deletions packages/faas-cli-command-core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,6 @@ export class CommandHookCore implements ICommandHooksCore {

// 加载本地插件
private async loadLocalPlugin(localPath) {
if (this.options.pluginType && this.options.pluginType.indexOf('local') === -1) {
this.debug('Skip Local Plugins');
return;
}
try {
if (this.options.config && this.options.config.servicePath && /^\./.test(localPath)) {
localPath = resolve(this.options.config.servicePath, localPath);
Expand All @@ -359,10 +355,6 @@ export class CommandHookCore implements ICommandHooksCore {

// 加载npm包插件
private async loadNpmPlugins() {
if (this.options.pluginType && this.options.pluginType.indexOf('npm') === -1) {
this.debug('Skip Npm Plugins');
return;
}
for (const npmPath of this.npmPlugin) {
await this.loadNpm(npmPath, this.options.options.npm || this.options.npm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface IOptions {
displayUsage?: any; // 使用帮助的展示处理
point?: any; // 埋点 (type: string, commandsArray: string[], commandInfo: any, this);
npm?: string; // 使用何种npm加速
pluginType?: string;
}

export interface ICommandHooksCore {
Expand Down
8 changes: 6 additions & 2 deletions packages/faas-cli-plugin-invoke/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { writeWrapper } from '@midwayjs/serverless-spec-builder';
import { createRuntime } from '@midwayjs/runtime-mock';
import * as FCTrigger from '@midwayjs/serverless-fc-trigger';
import { resolve, relative, join } from 'path';
import { tmpdir } from 'os';
import { FaaSStarterClass, cleanTarget } from './utils';
import { ensureFileSync, existsSync, writeFileSync, remove, readFileSync, copy } from 'fs-extra';
import { ensureFileSync, existsSync, writeFileSync, remove, readFileSync, copy, mkdirSync } from 'fs-extra';
export * from './invoke';
const commonLock: any = {};
enum LOCK_TYPE {
Expand All @@ -28,7 +29,7 @@ export class FaaSInvokePlugin extends BasePlugin {
buildLockPath: string;
entryInfo: any;
fileChanges: any;
defaultTmpFaaSOut = './node_modules/.faas_out';
defaultTmpFaaSOut = resolve(tmpdir(), `faas_out_${Date.now()}`);
commands = {
invoke: {
usage: '',
Expand Down Expand Up @@ -233,6 +234,9 @@ export class FaaSInvokePlugin extends BasePlugin {
this.core.debug('Compile', this.codeAnalyzeResult);
try {
const dest = join(this.buildDir, 'dist');
if (!existsSync(dest)) {
mkdirSync(dest);
}
await compileWithOptions(this.baseDir, dest, {
include: [].concat(this.fileChanges)
});
Expand Down
3 changes: 1 addition & 2 deletions packages/faas-cli-plugin-invoke/src/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export async function invoke (options: InvokeOptions) {
verbose: options.verbose,
resultType: 'store'
},
log: console,
pluginType: 'local'
log: console
});
core.addPlugin(FaaSInvokePlugin);
await core.ready();
Expand Down
2 changes: 1 addition & 1 deletion packages/faas-util-ts-compile/src/codeAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CodeAnalysis {
async start() {
this.loadSpec();

const parsedCli = findAndParseTsConfig(this.options.baseDir, undefined, undefined, { include: [].concat(this.options.sourceDir) });
const parsedCli = findAndParseTsConfig(this.options.baseDir, undefined, undefined, undefined, { include: [].concat(this.options.sourceDir) });
const compilerOptions = parsedCli.options;
const program = ts.createProgram(parsedCli.fileNames, compilerOptions);
this.checker = program.getTypeChecker();
Expand Down

0 comments on commit 7c2d000

Please sign in to comment.