mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Add feature flag in setup for python support.
This commit is contained in:
parent
6b208a8730
commit
c6bcd6f646
13 changed files with 413 additions and 100 deletions
|
|
@ -1,8 +1,9 @@
|
|||
/**
|
||||
* @type {{loggingLevel: string | undefined}}
|
||||
* @type {{loggingLevel: string | undefined, includePython: boolean}}
|
||||
*/
|
||||
const state = {
|
||||
loggingLevel: undefined,
|
||||
includePython: false,
|
||||
};
|
||||
|
||||
const SAFE_CHAIN_ARG_PREFIX = "--safe-chain-";
|
||||
|
|
@ -27,6 +28,7 @@ export function initializeCliArguments(args) {
|
|||
}
|
||||
|
||||
setLoggingLevel(safeChainArgs);
|
||||
setIncludePython(args);
|
||||
|
||||
return remainingArgs;
|
||||
}
|
||||
|
|
@ -64,3 +66,31 @@ function setLoggingLevel(args) {
|
|||
export function getLoggingLevel() {
|
||||
return state.loggingLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} args
|
||||
*/
|
||||
function setIncludePython(args) {
|
||||
// This flag doesn't have the --safe-chain- prefix because
|
||||
// it is only used for the safe-chain command itself and
|
||||
// not when wrapped around package manager commands.
|
||||
state.includePython = hasFlagArg(args, "--include-python");
|
||||
}
|
||||
|
||||
export function includePython() {
|
||||
return state.includePython;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} args
|
||||
* @param {string} flagName
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function hasFlagArg(args, flagName) {
|
||||
for (const arg of args) {
|
||||
if (arg.toLowerCase() === flagName.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue