@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
61 lines (60 loc) • 2.11 kB
JavaScript
;
/* Socket Lib - Built with esbuild */
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var shadow_exports = {};
__export(shadow_exports, {
shouldSkipShadow: () => shouldSkipShadow
});
module.exports = __toCommonJS(shadow_exports);
var import_path = require("./path");
function shouldSkipShadow(binPath, options) {
const { cwd = process.cwd(), win32 = false } = {
__proto__: null,
...options
};
if (win32 && binPath) {
return true;
}
const userAgent = process.env["npm_config_user_agent"];
if (userAgent?.includes("exec") || userAgent?.includes("npx") || userAgent?.includes("dlx")) {
return true;
}
const normalizedCwd = (0, import_path.normalizePath)(cwd);
const npmCache = process.env["npm_config_cache"];
if (npmCache && normalizedCwd.includes((0, import_path.normalizePath)(npmCache))) {
return true;
}
const tempPatterns = [
// npm's npx cache directory
"_npx",
// pnpm dlx temporary store
".pnpm-store",
// Common dlx directory prefix
"dlx-",
// Yarn Berry PnP virtual packages.
".yarn/$$",
// Yarn on Windows uses normalized forward slash paths.
"AppData/Local/Temp/xfs-"
];
return tempPatterns.some((pattern) => normalizedCwd.includes(pattern));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
shouldSkipShadow
});