mirror of
https://github.com/actions/toolkit
synced 2025-05-10 09:03:02 +00:00
Exec: throw error when cwd option does not exist (#793)
* Exec: throw error when cwd option does not exist * Simplify promise rejection
This commit is contained in:
parent
fecf6cdd59
commit
09e59b9a5c
2 changed files with 21 additions and 1 deletions
|
@ -538,6 +538,22 @@ describe('@actions/exec', () => {
|
|||
expect(output.trim()).toBe(`args[0]: "hello"${os.EOL}args[1]: "world"`)
|
||||
})
|
||||
|
||||
it('Exec roots throws friendly error when bad cwd is specified', async () => {
|
||||
const execOptions = getExecOptions()
|
||||
execOptions.cwd = 'nonexistent/path'
|
||||
|
||||
await expect(exec.exec('ls', ['-all'], execOptions)).rejects.toThrowError(
|
||||
`The cwd: ${execOptions.cwd} does not exist!`
|
||||
)
|
||||
})
|
||||
|
||||
it('Exec roots does not throw when valid cwd is provided', async () => {
|
||||
const execOptions = getExecOptions()
|
||||
execOptions.cwd = './'
|
||||
|
||||
await expect(exec.exec('ls', ['-all'], execOptions)).resolves.toBe(0)
|
||||
})
|
||||
|
||||
it('Exec roots relative tool path using rooted options.cwd', async () => {
|
||||
let command: string
|
||||
if (IS_WINDOWS) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue