mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-07 16:13:16 +08:00
Add core.isDebug() to check whether actions_step_debug is on or not. (#278)
This commit is contained in:
@@ -82,6 +82,12 @@ try {
|
||||
core.warning('myInput was not set');
|
||||
}
|
||||
|
||||
if (core.isDebug()) {
|
||||
// curl -v https://github.com
|
||||
} else {
|
||||
// curl https://github.com
|
||||
}
|
||||
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -177,6 +177,19 @@ describe('@actions/core', () => {
|
||||
it('getState gets wrapper action state', () => {
|
||||
expect(core.getState('TEST_1')).toBe('state_val')
|
||||
})
|
||||
|
||||
it('isDebug check debug state', () => {
|
||||
const current = process.env['RUNNER_DEBUG']
|
||||
try {
|
||||
delete process.env.RUNNER_DEBUG
|
||||
expect(core.isDebug()).toBe(false)
|
||||
|
||||
process.env['RUNNER_DEBUG'] = '1'
|
||||
expect(core.isDebug()).toBe(true)
|
||||
} finally {
|
||||
process.env['RUNNER_DEBUG'] = current
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// Assert that process.stdout.write calls called only with the given arguments.
|
||||
|
||||
@@ -102,6 +102,13 @@ export function setFailed(message: string): void {
|
||||
// Logging Commands
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets whether Actions Step Debug is on or not
|
||||
*/
|
||||
export function isDebug(): boolean {
|
||||
return process.env['RUNNER_DEBUG'] === '1'
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes debug message to user log
|
||||
* @param message debug message
|
||||
|
||||
Reference in New Issue
Block a user