Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
outputFileSync,
copySync,
removeSync,
writeJsonSync,
ensureDirSync
} from "fs-extra";
import { join } from "path";
import { watch } from "chokidar";
import { debounce } from "lodash";
/**
* Monkey patch bespoken's NodeUtil.resetCache method to make it work with symlinks --
* Due to limitations of serverless project, symlinks are often needed to share code between stacks --
* allowing code reload to work with serverless projects that use symlinks is useful ...
*/
NodeUtil.resetCache = function () {
// don't use a directory prefix when clearing require cache because the cache entry corresponds to
// resolved filename -- if project uses symlinks the underlying file might be a path outside of project base directory
// NOTE: this is true even if actual require(...) call refers to a path within project directory ...
// let directory: string = process.cwd();
for (const file of Object.keys(require.cache)) {
// if (file.startsWith(directory) && file.indexOf("node_modules") === -1) {
if (file.indexOf("node_modules") === -1) {
delete require.cache[require.resolve(file)];
}
}
};
/**
Create a directory structure with passthru modules for each specified handler
Example: