summaryrefslogtreecommitdiff
path: root/cli/fmt.rs
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2020-05-08 03:39:00 +0900
committerGitHub <noreply@github.com>2020-05-07 14:39:00 -0400
commit93cf3bd5341d5985201ea0905280082d5a3310f9 (patch)
tree1eac1afa8813e00cb47b0051b73c987889b086d2 /cli/fmt.rs
parent9a8d94842044c5d91ce8ac09ed96c0e184d842b2 (diff)
feat: format deno bundle output (#5139)
Diffstat (limited to 'cli/fmt.rs')
-rw-r--r--cli/fmt.rs7
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"