From b25131ed65496c9cf0f616f761517590aa16d120 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 10 Dec 2020 08:54:02 +0100 Subject: 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 --- src/config/not_validated.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/config') 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, + #[getset(get = "pub")] + script_linter: Option, + #[serde(default = "default_script_shebang")] #[getset(get = "pub")] shebang: String, @@ -86,6 +89,12 @@ pub struct NotValidatedConfiguration { impl NotValidatedConfiguration { pub fn validate(self) -> Result { + 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())) } -- cgit v1.2.3