feat: use debug logging when in debug mode (#128) (#129)

* feat: use debug logging when in debug mode (#128)

* chore: remove unnecessary getExperimental function

* chore: fix setupMise typing

As `core.getInput` returns always a string, the type of `version` in
`setupMise` should be just a `string`. When the string is empty it means
to use the latest version. This could be made cleaner but this is how it
works.

* feat: only set MISE_LOG_LEVEL when required

Previously MISE_LOG_LEVEL was always set, even when log_level parameter
wasn't configured. This changes that behaviour so that the environment
variable is only set when log_level is set by the user and that the
MISE_LOG_LEVEL is set to debug only for this action when in debug mode.

---------

Co-authored-by: Jeff Dickey <216188+jdx@users.noreply.github.com>
This commit is contained in:
Maximilian Remming 2024-10-25 19:48:49 +03:00 committed by GitHub
parent e3088a551c
commit cc7f0e6690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 470 additions and 461 deletions

20
dist/index.js generated vendored
View file

@ -62462,9 +62462,11 @@ async function setEnvVars() {
core.exportVariable(k, v);
}
};
if (getExperimental())
if (core.getBooleanInput('experimental'))
set('MISE_EXPERIMENTAL', '1');
set('MISE_LOG_LEVEL', core.getInput('log_level') || 'info');
const logLevel = core.getInput('log_level');
if (logLevel)
set('MISE_LOG_LEVEL', logLevel);
set('MISE_TRUSTED_CONFIG_PATHS', process.cwd());
set('MISE_YES', '1');
const shimsDir = path.join((0, utils_1.miseDir)(), 'shims');
@ -62529,10 +62531,6 @@ async function setupMise(version) {
}
core.addPath(miseBinDir);
}
function getExperimental() {
const experimentalString = core.getInput('experimental');
return experimentalString === 'true';
}
async function setToolVersions() {
const toolVersions = core.getInput('tool_versions');
if (toolVersions) {
@ -62561,11 +62559,17 @@ const mise = async (args) => core.group(`Running mise ${args.join(' ')}`, async
const cwd = core.getInput('working_directory') ||
core.getInput('install_dir') ||
process.cwd();
const env = core.isDebug()
? { MISE_LOG_LEVEL: 'debug', ...process.env }
: undefined;
if (args.length === 1) {
return exec.exec(`mise ${args}`, [], { cwd });
return exec.exec(`mise ${args}`, [], {
cwd,
env
});
}
else {
return exec.exec('mise', args, { cwd });
return exec.exec('mise', args, { cwd, env });
}
});
const writeFile = async (p, body) => core.group(`Writing ${p}`, async () => {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -40,8 +40,11 @@ async function setEnvVars(): Promise<void> {
core.exportVariable(k, v)
}
}
if (getExperimental()) set('MISE_EXPERIMENTAL', '1')
set('MISE_LOG_LEVEL', core.getInput('log_level') || 'info')
if (core.getBooleanInput('experimental')) set('MISE_EXPERIMENTAL', '1')
const logLevel = core.getInput('log_level')
if (logLevel) set('MISE_LOG_LEVEL', logLevel)
set('MISE_TRUSTED_CONFIG_PATHS', process.cwd())
set('MISE_YES', '1')
@ -93,7 +96,7 @@ async function restoreMiseCache(): Promise<void> {
core.info(`mise cache restored from key: ${cacheKey}`)
}
async function setupMise(version: string | undefined): Promise<void> {
async function setupMise(version: string): Promise<void> {
const miseBinDir = path.join(miseDir(), 'bin')
const miseBinPath = path.join(
miseBinDir,
@ -118,11 +121,6 @@ async function setupMise(version: string | undefined): Promise<void> {
core.addPath(miseBinDir)
}
function getExperimental(): boolean {
const experimentalString = core.getInput('experimental')
return experimentalString === 'true'
}
async function setToolVersions(): Promise<void> {
const toolVersions = core.getInput('tool_versions')
if (toolVersions) {
@ -157,10 +155,17 @@ const mise = async (args: string[]): Promise<number> =>
core.getInput('working_directory') ||
core.getInput('install_dir') ||
process.cwd()
const env = core.isDebug()
? { MISE_LOG_LEVEL: 'debug', ...process.env }
: undefined
if (args.length === 1) {
return exec.exec(`mise ${args}`, [], { cwd })
return exec.exec(`mise ${args}`, [], {
cwd,
env
})
} else {
return exec.exec('mise', args, { cwd })
return exec.exec('mise', args, { cwd, env })
}
})