Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare explicitly the --watch option on invoke #257

Merged
merged 1 commit into from Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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