summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-12-19 13:01:26 -0500
committerGitHub <noreply@github.com>2018-12-19 13:01:26 -0500
commit2351df72db2be5906a7441e16c883926051284b1 (patch)
tree7f294f9ba08d57ae681f850ccabf2965a8b36075
parenta3d164df917536c702775af1937569825fc5ceaf (diff)
Fix prettier version (denoland/deno_std#27)
Original: https://github.com/denoland/deno_std/commit/772698f4d2b65d81118f6f70232a4eccb1becc83
-rwxr-xr-xformat.ts25
1 files changed, 24 insertions, 1 deletions
diff --git a/format.ts b/format.ts
index 251cba1ed..25a56641d 100755
--- a/format.ts
+++ b/format.ts
@@ -1,8 +1,31 @@
#!/usr/bin/env deno --allow-run
+// Copyright 2018 the Deno authors. All rights reserved. MIT license.
-import { exit, run } from "deno";
+import { readAll, exit, run } from "deno";
+
+async function checkVersion() {
+ const prettierVersion = run({
+ args: ["bash", "-c", "prettier --version"],
+ stdout: "piped"
+ });
+ const b = await readAll(prettierVersion.stdout);
+ const s = await prettierVersion.status();
+ if (s.code != 0) {
+ console.log("error calling prettier --version error");
+ exit(s.code);
+ }
+ const version = new TextDecoder().decode(b).trim();
+ const requiredVersion = "1.15";
+ if (!version.startsWith(requiredVersion)) {
+ console.log(`Required prettier version: ${requiredVersion}`);
+ console.log(`Installed prettier version: ${version}`);
+ exit(1);
+ }
+}
async function main() {
+ await checkVersion();
+
const prettier = run({
args: ["bash", "-c", "prettier --write *.ts **/*.ts"]
});