summaryrefslogtreecommitdiff
path: root/cli/fmt.rs
diff options
context:
space:
mode:
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"