mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 08:52:35 +00:00
feat(validate-cmd-file): async validation
This commit is contained in:
parent
a5fbebd976
commit
3154895fb3
1 changed files with 13 additions and 12 deletions
|
|
@ -119,22 +119,23 @@ class Renovate {
|
|||
|
||||
private async validateDockerCmdFileArgument(): Promise<void> {
|
||||
const dockerCmdFile = this.input.getDockerCmdFile();
|
||||
if (dockerCmdFile !== null) {
|
||||
if (dockerCmdFile === null) return;
|
||||
|
||||
try {
|
||||
const s = await fs.stat(dockerCmdFile);
|
||||
if (!s.isFile)
|
||||
throw new Error(`dockerCmdFile '${dockerCmdFile}' MUST be a file`);
|
||||
if (
|
||||
!fs.existsSync(dockerCmdFile) ||
|
||||
!fs.statSync(dockerCmdFile).isFile()
|
||||
) {
|
||||
throw new Error(
|
||||
`dockerCmdFile '${dockerCmdFile}' MUST be an existing file`,
|
||||
);
|
||||
}
|
||||
try {
|
||||
fs.accessSync(dockerCmdFile, fs.constants.R_OK | fs.constants.X_OK);
|
||||
} catch {
|
||||
(s.mode & fs.constants.R_OK) === 0 ||
|
||||
(s.mode & fs.constants.X_OK) === 0
|
||||
)
|
||||
throw new Error(
|
||||
`dockerCmdFile '${dockerCmdFile}' MUST have read and execute rights`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error && 'code' in err && err.code === 'ENOENT')
|
||||
throw new Error(`dockerCmdFile '${dockerCmdFile}' does not exist`);
|
||||
throw new Error(err as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue