From 275a2b018543f4be368548248ac48ca901cde209 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Tue, 9 Nov 2021 16:44:12 +0100 Subject: [PATCH] Declare explicitly the `--watch` option on `invoke` --- src/Serverless.d.ts | 19 ++++++++++++++++++- src/index.ts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Serverless.d.ts b/src/Serverless.d.ts index f5096921..7c3e9f2d 100644 --- a/src/Serverless.d.ts +++ b/src/Serverless.d.ts @@ -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 } -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index 09ec228b..bba14c0c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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()