MCPcopy Create free account
hub / github.com/conventional-changelog/commitlint / getEditValue

Function getEditValue

@commitlint/cli/src/cli.ts:491–532  ·  view source on GitHub ↗
(flags: CliFlags)

Source from the content-addressed store, hash-verified

489}
490
491function getEditValue(flags: CliFlags) {
492 if (flags.env) {
493 if (!(flags.env in process.env)) {
494 throw new Error(
495 `Received '${flags.env}' as value for -E | --env, but environment variable '${flags.env}' is not available globally`,
496 );
497 }
498 return process.env[flags.env];
499 }
500 const { edit } = flags;
501 // If the edit flag is set but empty (i.e '-e') we default
502 // to .git/COMMIT_EDITMSG
503 if (edit === "") {
504 return true;
505 }
506 if (typeof edit === "boolean") {
507 return edit;
508 }
509 // The recommended method to specify -e with husky was `commitlint -e $HUSKY_GIT_PARAMS`
510 // This does not work properly with win32 systems, where env variable declarations
511 // use a different syntax
512 // See https://github.com/conventional-changelog/commitlint/issues/103 for details
513 // This has been superseded by the `-E GIT_PARAMS` / `-E HUSKY_GIT_PARAMS`
514 const isGitParams = edit === "$GIT_PARAMS" || edit === "%GIT_PARAMS%";
515 const isHuskyParams = edit === "$HUSKY_GIT_PARAMS" || edit === "%HUSKY_GIT_PARAMS%";
516
517 if (isGitParams || isHuskyParams) {
518 console.warn(`Using environment variable syntax (${edit}) in -e |\
519--edit is deprecated. Use '{-E|--env} HUSKY_GIT_PARAMS instead'`);
520
521 if (isGitParams && "GIT_PARAMS" in process.env) {
522 return process.env.GIT_PARAMS;
523 }
524 if ("HUSKY_GIT_PARAMS" in process.env) {
525 return process.env.HUSKY_GIT_PARAMS;
526 }
527 throw new Error(
528 `Received ${edit} as value for -e | --edit, but GIT_PARAMS or HUSKY_GIT_PARAMS are not available globally.`,
529 );
530 }
531 return edit;
532}
533
534async function loadConfig(flags: CliFlags): Promise<QualifiedConfig> {
535 const loaded = await load(getSeed(flags), {

Callers 1

normalizeFlagsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected