(serverless, options)
| 8 | |
| 9 | class SlsBrowserify { |
| 10 | constructor(serverless, options) { |
| 11 | this.serverless = serverless; |
| 12 | this.options = options; |
| 13 | this.globalBrowserifyConfig = {}; |
| 14 | |
| 15 | Object.assign( |
| 16 | this, |
| 17 | validate, |
| 18 | configure, |
| 19 | bundle |
| 20 | ); |
| 21 | |
| 22 | this.commands = { |
| 23 | browserify: { |
| 24 | usage: 'Bundle NodeJS lambda with Browserify', |
| 25 | lifecycleEvents: [ |
| 26 | 'validate', |
| 27 | 'bundle', |
| 28 | ], |
| 29 | options: { |
| 30 | out: { |
| 31 | usage: 'Path to output directory', |
| 32 | shortcut: 'o', |
| 33 | }, |
| 34 | function: { |
| 35 | usage: 'Name of the function', |
| 36 | shortcut: 'f', |
| 37 | required: true, |
| 38 | }, |
| 39 | }, |
| 40 | commands: {}, |
| 41 | }, |
| 42 | }; |
| 43 | |
| 44 | this.hooks = { |
| 45 | //Handle `sls deploy` |
| 46 | 'before:deploy:createDeploymentArtifacts': () => BbPromise.bind(this) |
| 47 | .then(this.validate) |
| 48 | .then(this.globalConfig) |
| 49 | .then(() => { |
| 50 | const functionNames = this.serverless.service.getAllFunctions(); |
| 51 | const bundleQueue = functionNames.map(functionName => { |
| 52 | return this.bundle(functionName); |
| 53 | }); |
| 54 | |
| 55 | return BbPromise.all(bundleQueue); |
| 56 | }) |
| 57 | .catch(handleSkip), |
| 58 | |
| 59 | //Handle `sls deploy function` |
| 60 | 'before:deploy:function:packageFunction': () => BbPromise.bind(this) |
| 61 | .then(this.validate) |
| 62 | .then(this.globalConfig) |
| 63 | .then(() => this.bundle(this.options.function)) |
| 64 | .catch(handleSkip), |
| 65 | |
| 66 | //Handle `sls browserify` |
| 67 | 'browserify:validate': () => BbPromise.bind(this) |
nothing calls this directly
no outgoing calls
no test coverage detected