diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-10 08:54:02 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-11 10:58:29 +0100 |
commit | b25131ed65496c9cf0f616f761517590aa16d120 (patch) | |
tree | bf0076fe1dc29e87ac4ea7b7b46ecd1339d47173 /src/config | |
parent | b7f6276b1d3b9678f9cafa377ec8307845c3446b (diff) |
Add feature: script linting
This patch adds script linting via a configurable script.
With this patch, the configuration can point to a script or program that
gets the packaging script on STDIN and might exit with a nonzero value
on error.
The simplest script I can think of that adds value is:
#!/bin/bash
shellcheck -
to run the packaging script through shellcheck.
stdout and stderr of the linting script are printed in case of non-zero
return value.
Linting can be disabled by not setting the script in the config or by
passing a commandline flag to skip linting (a warning will be printed in
this case).
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/not_validated.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs index bdbce89..9f99f80 100644 --- a/src/config/not_validated.rs +++ b/src/config/not_validated.rs @@ -38,6 +38,9 @@ pub struct NotValidatedConfiguration { #[getset(get = "pub")] script_highlight_theme: Option<String>, + #[getset(get = "pub")] + script_linter: Option<PathBuf>, + #[serde(default = "default_script_shebang")] #[getset(get = "pub")] shebang: String, @@ -86,6 +89,12 @@ pub struct NotValidatedConfiguration { impl NotValidatedConfiguration { pub fn validate(self) -> Result<Configuration> { + if let Some(linter) = self.script_linter.as_ref() { + if !linter.is_file() { + return Err(anyhow!("Lint script is not a file: {}", linter.display())) + } + } + if !self.staging_directory.is_dir() { return Err(anyhow!("Not a directory: staging = {}", self.staging_directory.display())) } |