mirror of https://github.com/actions/toolkit
add support for using a shell to run commands
parent
bfd29dcef8
commit
654dba3681
|
@ -153,6 +153,23 @@ describe('@actions/exec', () => {
|
|||
expect(output.trim()).toBe(`hello`)
|
||||
})
|
||||
|
||||
it('Runs exec successfully with shell wildcard substitution', async () => {
|
||||
let tool: string
|
||||
let args: string[]
|
||||
let opts: im.ExecOptions
|
||||
if (IS_WINDOWS) {
|
||||
tool = 'cmd'
|
||||
args = ['/c', 'echo', 'hello']
|
||||
opts = {shell: process.env.ComSpec}
|
||||
} else {
|
||||
tool = 'ls'
|
||||
args = ['-l', '*.md']
|
||||
opts = {shell: '/bin/sh'}
|
||||
}
|
||||
const exitCode = await exec.exec(tool, args, opts)
|
||||
expect(exitCode).toBe(0)
|
||||
})
|
||||
|
||||
it('Exec fails with error on bad call', async () => {
|
||||
const _testExecOptions = getExecOptions()
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ export interface ExecOptions {
|
|||
/** optional. defaults to false */
|
||||
silent?: boolean
|
||||
|
||||
/** optional. Runs command inside of a shell. A different shell can be specified as a string. Defaults to false */
|
||||
shell?: boolean | string
|
||||
|
||||
/** optional out stream to use. Defaults to process.stdout */
|
||||
outStream?: stream.Writable
|
||||
|
||||
|
|
|
@ -377,6 +377,7 @@ export class ToolRunner extends events.EventEmitter {
|
|||
const result = <child.SpawnOptions>{}
|
||||
result.cwd = options.cwd
|
||||
result.env = options.env
|
||||
result.shell = options.shell
|
||||
result['windowsVerbatimArguments'] =
|
||||
options.windowsVerbatimArguments || this._isCmdFile()
|
||||
if (options.windowsVerbatimArguments) {
|
||||
|
|
Loading…
Reference in New Issue