mirror of https://github.com/actions/toolkit
Add docs and wrapper for "echo" command (#411)
* Add docs and wrapper for "echo" command * Update parameter to enabledpull/417/head
parent
3c125ce4e0
commit
05e39f551d
|
@ -122,7 +122,7 @@ echo "::save-state name=FOO::foovalue"
|
||||||
|
|
||||||
### Log Level
|
### Log Level
|
||||||
|
|
||||||
Finally, there are several commands to emit different levels of log output:
|
There are several commands to emit different levels of log output:
|
||||||
|
|
||||||
| log level | example usage |
|
| log level | example usage |
|
||||||
|---|---|
|
|---|---|
|
||||||
|
@ -130,6 +130,29 @@ Finally, there are several commands to emit different levels of log output:
|
||||||
| warning | `echo "::warning::My warning message"` |
|
| warning | `echo "::warning::My warning message"` |
|
||||||
| error | `echo "::error::My error message"` |
|
| error | `echo "::error::My error message"` |
|
||||||
|
|
||||||
|
### Command Echoing
|
||||||
|
By default, the echoing of commands to stdout only occurs if [Step Debugging is enabled](./actions-debugging.md#How-to-Access-Step-Debug-Logs)
|
||||||
|
|
||||||
|
You can enable or disable this for the current step by using the `echo` command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "::echo::on"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also disable echoing.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "::echo::off"
|
||||||
|
```
|
||||||
|
|
||||||
|
This is wrapped by the core method:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function setCommandEcho(enabled: boolean): void {}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `add-mask`, `debug`, `warning` and `error` commands do not support echoing.
|
||||||
|
|
||||||
### Command Prompt
|
### Command Prompt
|
||||||
CMD processes the `"` character differently from other shells when echoing. In CMD, the above snippets should have the `"` characters removed in order to correctly process. For example, the set output command would be:
|
CMD processes the `"` character differently from other shells when echoing. In CMD, the above snippets should have the `"` characters removed in order to correctly process. For example, the set output command would be:
|
||||||
```cmd
|
```cmd
|
||||||
|
|
|
@ -239,6 +239,16 @@ describe('@actions/core', () => {
|
||||||
process.env['RUNNER_DEBUG'] = current
|
process.env['RUNNER_DEBUG'] = current
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('setCommandEcho can enable echoing', () => {
|
||||||
|
core.setCommandEcho(true)
|
||||||
|
assertWriteCalls([`::echo::on${os.EOL}`])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('setCommandEcho can disable echoing', () => {
|
||||||
|
core.setCommandEcho(false)
|
||||||
|
assertWriteCalls([`::echo::off${os.EOL}`])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
// Assert that process.stdout.write calls called only with the given arguments.
|
||||||
|
|
|
@ -87,6 +87,15 @@ export function setOutput(name: string, value: any): void {
|
||||||
issueCommand('set-output', {name}, value)
|
issueCommand('set-output', {name}, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||||||
|
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function setCommandEcho(enabled: boolean): void {
|
||||||
|
issue('echo', enabled ? 'on' : 'off')
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Results
|
// Results
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue