Last active
May 13, 2019 23:02
-
-
Save ajmath/db7a1210cf9e01403e3dfb6004c1b89a to your computer and use it in GitHub Desktop.
serverless-plugin-typescript: Workaround for issue with excluding dev dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package: | |
excludeDevDependencies: false | |
exclude: ${file(sls-exclude.js):get} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-nocheck | |
const childProcess = require("child_process"); | |
const path = require("path"); | |
const getDeps = (env) => { | |
const args = { encoding: "utf8" }; | |
return childProcess.execSync(`npm ls --${env}=true --parseable=true --long=false --silent || true`, args).split("\n"); | |
}; | |
module.exports.get = () => { | |
const slsDir = path.resolve("./") + "/"; | |
const prodDeps = getDeps("prod"); | |
const devDeps = getDeps("dev"); | |
const devFiles = devDeps.filter((d) => !prodDeps.includes(d)).map((d) => d.replace(slsDir, "") + "/**"); | |
return [ | |
...devFiles, | |
"yarn-error.log" // Add additional exclusions here | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment