snyk-docker-plugin
Version:
Snyk CLI docker plugin
36 lines • 1.46 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNodeJsTsAppFileContentAction = exports.getNodeAppFileContentAction = void 0;
const path_1 = require("path");
const stream_utils_1 = require("../../stream-utils");
const nodeAppFiles = ["package.json", "package-lock.json", "yarn.lock"];
const deletedAppFiles = nodeAppFiles.map((file) => ".wh." + file);
const nodeJsTsAppFileSuffixes = [
".js",
".ts",
"package.json",
"package-lock.json",
];
const excludedNodeJsTsAppFileSuffixes = [".d.ts"];
function filePathMatches(filePath) {
const fileName = (0, path_1.basename)(filePath);
return nodeAppFiles.includes(fileName) || deletedAppFiles.includes(fileName);
}
exports.getNodeAppFileContentAction = {
actionName: "node-app-files",
filePathMatches,
callback: stream_utils_1.streamToString,
};
function nodeJsTsAppFilePathMatches(filePath) {
return (!filePath.includes("node_modules/") &&
// "/usr/" should not include 1st party code
!filePath.startsWith("/usr/") &&
nodeJsTsAppFileSuffixes.some((suffix) => filePath.endsWith(suffix)) &&
!excludedNodeJsTsAppFileSuffixes.some((excludedSuffix) => filePath.endsWith(excludedSuffix)));
}
exports.getNodeJsTsAppFileContentAction = {
actionName: "node-js-ts-app-files",
filePathMatches: nodeJsTsAppFilePathMatches,
callback: stream_utils_1.streamToString,
};
//# sourceMappingURL=static.js.map
;