From 2ede988973cf6387490523315c4de3ccf87ed3d9 Mon Sep 17 00:00:00 2001 From: Fayssal SMAWI Date: Wed, 23 Jun 2021 19:58:50 +0100 Subject: [PATCH] feat| Added support for custom build directory --- README.md | 10 ++++++++-- build.js | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e05684f..4ca7378 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,17 @@ Where: # Run Plugin ```bash -sls step-functions-offline --stateMachine={{name}} --event={{path to event file}} +sls step-functions-offline --stateMachine={{name}} --event={{path to event file}} --buildDir={{build-path}} ``` -- `name`: name of state machine in section state functions. In example above it's `foo`. +- `stateMachine`: name of state machine in section state functions. In example above it's `foo`. - `event`: input values for execution in JSON format (optional) +- `buildDir`: path to the build directory, eg: .webpack/.build (optional) + +In case you have a custom build directory use: + ```bash +sls step-functions-offline --stateMachine={{name}} --event={{path to event file}} --buildDir={{build-path}} +``` If you want to know where you are (in offline mode or not) you can use env variable `STEP_IS_OFFLINE`. diff --git a/build.js b/build.js index 6a50c2b..6d4553f 100644 --- a/build.js +++ b/build.js @@ -17,7 +17,8 @@ module.exports = { // }, // _findFunctionPathAndHandler(functionHandler) { - const dir = path.dirname(functionHandler); + const buildDir = this.options.buildDir ? `${this.options.buildDir}/` : ''; + const dir = `${buildDir}${path.dirname(functionHandler)}`; const handler = path.basename(functionHandler); const splitHandler = handler.split('.'); const filePath = `${dir}/${splitHandler[0]}.js`;