Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Specify a command to run when the image start.
By default the image run
`renovate`.
This option is useful to customize the image before running `renovate`.
It must be an existing executable file on the local system.
It must be an existing file on the local system and it must have execute permission.
It will be mounted to the docker container.

For example you can create a simple script like this one (let's call it
Expand Down
25 changes: 25 additions & 0 deletions src/renovate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ class Renovate {
if (/\s/.test(this.input.token.value)) {
throw new Error('Token MUST NOT contain whitespace');
}
this.validateConfigFileArgument();
this.validateDockerCmdFileArgument();
}

private validateConfigFileArgument(): void {
const configurationFile = this.input.configurationFile();
if (
configurationFile !== null &&
Expand All @@ -112,6 +116,27 @@ class Renovate {
);
}
}

private validateDockerCmdFileArgument(): void {
const dockerCmdFile = this.input.getDockerCmdFile();
if (dockerCmdFile !== null) {
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 {
throw new Error(
`dockerCmdFile '${dockerCmdFile}' MUST have read and execute rights`,
);
}
}
}
}

export default Renovate;