diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2020-05-08 03:39:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-07 14:39:00 -0400 |
commit | 93cf3bd5341d5985201ea0905280082d5a3310f9 (patch) | |
tree | 1eac1afa8813e00cb47b0051b73c987889b086d2 /cli/fmt.rs | |
parent | 9a8d94842044c5d91ce8ac09ed96c0e184d842b2 (diff) |
feat: format deno bundle output (#5139)
Diffstat (limited to 'cli/fmt.rs')
-rw-r--r-- | cli/fmt.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cli/fmt.rs b/cli/fmt.rs index 74d3d0eea..9b6e5975d 100644 --- a/cli/fmt.rs +++ b/cli/fmt.rs @@ -171,6 +171,13 @@ fn format_stdin(check: bool) -> Result<(), ErrBox> { Ok(()) } +/// Formats the given source text +pub fn format_text(source: &str) -> Result<String, ErrBox> { + dprint::Formatter::new(get_config()) + .format_text(&PathBuf::from("_tmp.ts"), &source) + .map_err(|e| OpError::other(e).into()) +} + fn files_str(len: usize) -> &'static str { if len == 1 { "file" |