@aikidosec/firewall
Version:
Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.
25 lines (24 loc) • 818 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEntrypointFromCLIArgs = getEntrypointFromCLIArgs;
const path_1 = require("path");
/**
* Determins the absolute path to the entrypoint of the application by parsing the CLI arguments passed to the process.
*/
function getEntrypointFromCLIArgs() {
const argv = process.argv;
if (argv.length < 2) {
return undefined;
}
let candidate = argv[1];
if (candidate === "inspect" || candidate === "debug") {
if (argv.length < 3) {
return undefined;
}
candidate = argv[2];
}
if (!candidate || candidate === "-" || candidate.startsWith("-")) {
return undefined;
}
return (0, path_1.isAbsolute)(candidate) ? candidate : (0, path_1.resolve)(candidate);
}