From a3b6ed32645f10cc1a68f433b9e35a716b517cf4 Mon Sep 17 00:00:00 2001 From: Piotr Konieczny Date: Tue, 21 Jan 2020 10:30:15 +0100 Subject: [PATCH 1/2] Added possiblity to use npm install options via config --- LayerManagerPlugin.js | 4 +++- README.md | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LayerManagerPlugin.js b/LayerManagerPlugin.js index a0f43c0..06a4fef 100644 --- a/LayerManagerPlugin.js +++ b/LayerManagerPlugin.js @@ -8,6 +8,7 @@ const fs = require('fs'); const DEFAULT_CONFIG = { installLayers: true, + installOptions: [], exportLayers: true, upgradeLayerReferences: true, exportPrefix: '${AWS::StackName}-' @@ -63,10 +64,11 @@ class LayerManagerPlugin { installLayer(path) { const nodeLayerPath = `${path}/nodejs`; + const installArgsString = this.config.installOptions ? this.config.installOptions.join(' ') : ''; if (fs.existsSync(nodeLayerPath)) { verbose(this, `Installing nodejs layer ${path}`); - execSync('npm install', { + execSync(`npm install ${installArgsString}`, { stdio: 'inherit', cwd: nodeLayerPath }); diff --git a/README.md b/README.md index d8a9a61..a5b1ee5 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,10 @@ You may customize the features by adding a `layerConfig` object under `custom`, custom: layerConfig: installLayers: + installOptions: exportLayers: upgradeLayerReferences: exportPrefix: ``` -By default, all config options are true and the `exportPrefix` is set to `${AWS:StackName}-`. +By default, all config options are true, the `exportPrefix` is set to `${AWS:StackName}-` and installOptions is an empty array. From 285b494f292f08a002f7fe68f70c8f2c8d7723c0 Mon Sep 17 00:00:00 2001 From: Piotr Konieczny Date: Tue, 21 Jan 2020 14:57:18 +0100 Subject: [PATCH 2/2] Added installOptions in tests (but no dedicated test case) --- test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.js b/test/test.js index 6be472f..a55906b 100644 --- a/test/test.js +++ b/test/test.js @@ -5,6 +5,7 @@ const DEFAULT_CONFIG = { exportLayers: true, exportPrefix: '${AWS::StackName}-', installLayers: true, + installOptions: [], upgradeLayerReferences: true };