mirror of
https://github.com/denoland/deno.git
synced 2024-11-23 15:16:54 -05:00
c164e696d7
Original: 297cf0975e
40 lines
1,016 B
TypeScript
Executable file
40 lines
1,016 B
TypeScript
Executable file
#!/usr/bin/env deno --allow-run
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
|
|
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 */**/*.ts *.md */**/*.md"
|
|
]
|
|
});
|
|
const s = await prettier.status();
|
|
exit(s.code);
|
|
}
|
|
|
|
main();
|