Skip to content

Commit

Permalink
Declare explicitly the --watch option on invoke (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Nov 22, 2021
1 parent 378f3be commit 4a9e3dd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Serverless.d.ts
Expand Up @@ -46,7 +46,24 @@ declare namespace Serverless {
individually?: boolean
}

type CommandsDefinition = Record<
string,
{
lifecycleEvents?: string[]
commands?: CommandsDefinition
usage?: string
options?: {
[name: string]: {
type: string
usage: string
required?: boolean
shortcut?: string
}
}
}
>

interface PluginManager {
spawn(command: string): Promise<void>
}
}
}
16 changes: 16 additions & 0 deletions src/index.ts
Expand Up @@ -16,11 +16,27 @@ export class TypeScriptPlugin {
serverless: Serverless.Instance
options: Serverless.Options
hooks: { [key: string]: Function }
commands: Serverless.CommandsDefinition

constructor(serverless: Serverless.Instance, options: Serverless.Options) {
this.serverless = serverless
this.options = options

this.commands = {
invoke: {
commands: {
local: {
options: {
watch: {
type: 'boolean',
usage: 'Watch file changes and re-invoke automatically the function'
}
}
}
}
}
}

this.hooks = {
'before:run:run': async () => {
await this.compileTs()
Expand Down

0 comments on commit 4a9e3dd

Please sign in to comment.