forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.js
executable file
·30 lines (28 loc) · 941 Bytes
/
format.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env -S deno run --unstable --allow-write --allow-read --allow-run --allow-net
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { join, ROOT_PATH } from "./util.js";
const subcommand = Deno.args.includes("--check") ? "check" : "fmt";
const configFile = join(ROOT_PATH, ".dprint.json");
const cmd = new Deno.Command("deno", {
args: [
"run",
"-A",
"--no-config",
"npm:[email protected]",
subcommand,
"--config=" + configFile,
],
cwd: ROOT_PATH,
stdout: "piped",
stderr: "inherit",
});
const { code, stdout } = await cmd.output();
// todo(dsherret): temporary until https://github.com/denoland/deno/pull/21359 gets released.
// Once it's released, just have stdout be inherited above and do `Deno.exit(code)` here.
const stdoutText = new TextDecoder().decode(stdout);
console.log(stdoutText);
if (stdoutText.length > 0) {
Deno.exit(20);
} else {
Deno.exit(code);
}