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

add hook *before:step-functions-offline:start* #313

Merged
merged 9 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const run = require('./lib/run');
const prepareLocalInvoke = require('./lib/prepareLocalInvoke');
const runPluginSupport = require('./lib/runPluginSupport');
const prepareOfflineInvoke = require('./lib/prepareOfflineInvoke');
const prepareStepOfflineInvoke = require('./lib/prepareStepOfflineInvoke');
const packExternalModules = require('./lib/packExternalModules');
const packageModules = require('./lib/packageModules');
const lib = require('./lib');
Expand Down Expand Up @@ -44,7 +45,8 @@ class ServerlessWebpack {
packageModules,
prepareLocalInvoke,
runPluginSupport,
prepareOfflineInvoke
prepareOfflineInvoke,
prepareStepOfflineInvoke
);

this.commands = {
Expand Down Expand Up @@ -153,6 +155,9 @@ class ServerlessWebpack {
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () => BbPromise.bind(this)
.then(this.prepareStepOfflineInvoke)
.then(this.compile)
};
}
}
Expand Down
24 changes: 24 additions & 0 deletions lib/prepareStepOfflineInvoke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const _ = require('lodash');
const path = require('path');

/**
* Special settings for use with serverless-step-functions-offline.
*/

module.exports = {
prepareStepOfflineInvoke() {
_.set(this.serverless, 'service.package.individually', false);

return this.serverless.pluginManager.spawn('webpack:validate')
.then(() => {
if (!this.options.location && !_.get(this.serverless, 'service.custom.stepFunctionsOffline.location')) {
_.set(this.serverless, 'service.custom.stepFunctionsOffline.location',
path.relative(this.serverless.config.servicePath, path.join(this.webpackOutputPath, 'service'))
);
}
return null;
});
}
};