UNPKG

serverless

Version:

Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more

50 lines (41 loc) 1.19 kB
'use strict'; class ServerlessPlugin { constructor(serverless, options) { this.serverless = serverless; this.options = options; this.commands = { welcome: { usage: 'Helps you start your first Serverless plugin', lifecycleEvents: ['hello', 'world'], options: { message: { usage: 'Specify the message you want to deploy ' + '(e.g. "--message \'My Message\'" or "-m \'My Message\'")', required: true, shortcut: 'm', }, }, }, }; this.hooks = { 'before:welcome:hello': this.beforeWelcome.bind(this), 'welcome:hello': this.welcomeUser.bind(this), 'welcome:world': this.displayHelloMessage.bind(this), 'after:welcome:world': this.afterHelloWorld.bind(this), }; } beforeWelcome() { this.serverless.cli.log('Hello from Serverless!'); } welcomeUser() { this.serverless.cli.log('Your message:'); } displayHelloMessage() { this.serverless.cli.log(`${this.options.message}`); } afterHelloWorld() { this.serverless.cli.log('Please come again!'); } } module.exports = ServerlessPlugin;