diff --git a/src/actions/autoinstall/get-root-params.js b/src/actions/autoinstall/get-root-params.js new file mode 100644 index 0000000..53a2b1d --- /dev/null +++ b/src/actions/autoinstall/get-root-params.js @@ -0,0 +1,16 @@ +let { existsSync, readFileSync } = require('fs') +let { join } = require('path') + +// Get params from root project that should be preserved in hydrated package.json +module.exports = function getRootParams ({ inv }) { + let root = inv._project.cwd + let packageJson = join(root, 'package.json') + + let package = existsSync(packageJson) && JSON.parse(readFileSync(packageJson)) || {} + + let result = {} + if (package.overrides) + result.overrides = package.overrides + + return result +} diff --git a/src/actions/autoinstall/index.js b/src/actions/autoinstall/index.js index 68aa748..fef6d9f 100644 --- a/src/actions/autoinstall/index.js +++ b/src/actions/autoinstall/index.js @@ -1,6 +1,7 @@ let { existsSync, renameSync, writeFileSync } = require('fs') let { join } = require('path') let getRootDeps = require('./get-root-deps') +let getRootParams = require('./get-root-params') let getSharedDeps = require('./get-shared-deps') let getLambdaDeps = require('./get-lambda-deps') @@ -73,7 +74,8 @@ module.exports = function autoinstaller (params) { dir, file: 'package.json', remove: [ 'package.json', 'package-lock.json' ], // Identify files for later removal - data: JSON.stringify(lambdaPackage, null, 2) + data: JSON.stringify(lambdaPackage, null, 2), + ...getRootParams() } // Autoinstall can be called on a directory that contains a package.json with `"type": "module"` (and no dependencies) // If we find such a case, kindly move the existing package.json aside until autoinstall ops are complete