Skip to content

Commit 4a9e3dd

Browse files
authored
Declare explicitly the --watch option on invoke (#257)
1 parent 378f3be commit 4a9e3dd

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Diff for: src/Serverless.d.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,24 @@ declare namespace Serverless {
4646
individually?: boolean
4747
}
4848

49+
type CommandsDefinition = Record<
50+
string,
51+
{
52+
lifecycleEvents?: string[]
53+
commands?: CommandsDefinition
54+
usage?: string
55+
options?: {
56+
[name: string]: {
57+
type: string
58+
usage: string
59+
required?: boolean
60+
shortcut?: string
61+
}
62+
}
63+
}
64+
>
65+
4966
interface PluginManager {
5067
spawn(command: string): Promise<void>
5168
}
52-
}
69+
}

Diff for: src/index.ts

+16
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,27 @@ export class TypeScriptPlugin {
1616
serverless: Serverless.Instance
1717
options: Serverless.Options
1818
hooks: { [key: string]: Function }
19+
commands: Serverless.CommandsDefinition
1920

2021
constructor(serverless: Serverless.Instance, options: Serverless.Options) {
2122
this.serverless = serverless
2223
this.options = options
2324

25+
this.commands = {
26+
invoke: {
27+
commands: {
28+
local: {
29+
options: {
30+
watch: {
31+
type: 'boolean',
32+
usage: 'Watch file changes and re-invoke automatically the function'
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
2440
this.hooks = {
2541
'before:run:run': async () => {
2642
await this.compileTs()

0 commit comments

Comments
 (0)