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

Commit

Permalink
feat: change serverless plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
echosoar committed Dec 10, 2019
1 parent 856e8f7 commit b1be100
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-mock/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class MockRuntime {
}

return new Promise((resolve, reject) => {
if (this.trigger.useCallback) {
if (this.trigger && this.trigger.useCallback) {
// 这个地方 callback 得调用 resolve
const cb = this.trigger.createCallback((err, result) => {
if (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { IServerless, ICommandOptions, ICommandParam } from '../../interface/midwayServerless';
export const hackInit = async(serverless: IServerless, commands: ICommandOptions, options: ICommandParam) => {
console.log('hack init');
};

export const hackRun = async (serverless: IServerless, commands: ICommandOptions, options: ICommandParam) => {
console.log('hack run');
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ProviderFc extends ProviderBase {

// 执行 package 打包
await this.callCommand('package', {
...this.options,
skipZip: true // 跳过压缩成zip
});
this.serverless.cli.log('Start deploy by @alicloud/fun');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Package extends CommandBase {
}
}
writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, ' '));
spinner.text = 'npm install';
spinner.text = `${this.options.npm || 'npm'} install`;
await this.npmInstall();
for (const localDepName in localDep) {
spinner.text = localDepName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ class ProviderTencent extends ProviderBase {
hooks['package:compileFunctions'].push({
pluginName: 'ProviderTencent',
hook: async () => {
this.serverless.processedInput.options.package = `.serverless/${artifact}`;
// 进行构建
await this.serverless.pluginManager.invoke.call(this.serverless.pluginManager, ['package'], true);
// 执行 package 打包
await this.callCommand('package', {
...this.options,
package: `.serverless/${artifact}`
});
},
});
// 修改打包文件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export class HelloService {
ctx: FaaSContext; // context

async handler(event, obj = {}) {
return 'hello world';
return 'hello world';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ functions:
parameters:
serviceId: ''
method: get
index2:
initializer: index.initializer
handler: index.handler2
events:
- apigw:
parameters:
serviceId: ''
method: get

plugins:
- test
Expand Down

0 comments on commit b1be100

Please sign in to comment.