-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support nginxbeautifier (#514)
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::process::Command; | ||
|
||
use crate::{error::MdsfError, execution::execute_command, runners::CommandType}; | ||
|
||
#[inline] | ||
fn set_nginxbeautifier_args(mut cmd: Command, file_path: &std::path::Path) -> Command { | ||
cmd.arg(file_path); | ||
cmd | ||
} | ||
|
||
#[inline] | ||
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> { | ||
let commands = [ | ||
CommandType::NodeModules("nginxbeautifier"), | ||
CommandType::Direct("nginxbeautifier"), | ||
CommandType::Npm("nginxbeautifier"), | ||
]; | ||
|
||
for (index, cmd) in commands.iter().enumerate() { | ||
let cmd = set_nginxbeautifier_args(cmd.build(), file_path); | ||
let execution_result = execute_command(cmd, file_path); | ||
|
||
if index == commands.len() - 1 { | ||
return execution_result; | ||
} | ||
|
||
if let Ok(r) = execution_result { | ||
if !r.0 { | ||
return Ok(r); | ||
} | ||
} | ||
} | ||
|
||
Ok((true, None)) | ||
} | ||
|
||
#[cfg(test)] | ||
mod test_nginxbeautifier {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "../tool.schema.json", | ||
"binary": "nginxbeautifier", | ||
"categories": ["formatter"], | ||
"commands": { | ||
"": ["$PATH"] | ||
}, | ||
"description": "Format and beautify nginx config files", | ||
"homepage": "https://github.com/vasilevich/nginxbeautifier", | ||
"languages": ["nginx"], | ||
"name": null, | ||
"npm": "nginxbeautifier", | ||
"php": null, | ||
"tests": [] | ||
} |