mirror of
https://github.com/actions/github-script.git
synced 2026-06-07 01:24:24 +00:00
refactor: extract working-directory validation into testable module
- Add src/working-directory.ts with validateWorkingDirectory() - Add __test__/working-directory.test.ts with 4 test cases - Update main.ts to use validation function - Throw clear error for non-existent or non-directory paths - Rebuild dist/index.js Addresses review feedback on #426
This commit is contained in:
parent
5ac99427a6
commit
7b9b30a1ea
4 changed files with 99 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ import {RequestRequestOptions} from '@octokit/types'
|
|||
import {callAsyncFunction} from './async-function'
|
||||
import {createConfiguredGetOctokit} from './create-configured-getoctokit'
|
||||
import {RetryOptions, getRetryOptions, parseNumberArray} from './retry-options'
|
||||
import {validateWorkingDirectory} from './working-directory'
|
||||
import {wrapRequire} from './wrap-require'
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
|
|
@ -62,8 +63,9 @@ async function main(): Promise<void> {
|
|||
const workingDirectory = core.getInput('working-directory')
|
||||
|
||||
if (workingDirectory) {
|
||||
core.info(`Changing working directory to ${workingDirectory}`)
|
||||
process.chdir(workingDirectory)
|
||||
const resolved = validateWorkingDirectory(workingDirectory)
|
||||
core.info(`Changing working directory to ${resolved}`)
|
||||
process.chdir(resolved)
|
||||
}
|
||||
|
||||
// Wrap getOctokit so secondary clients inherit retry, logging,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue