summaryrefslogtreecommitdiff
path: root/tools/format.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-07-08 02:24:29 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-07-08 13:40:18 -0400
commitf917c5e722d7ee5abd58704eb0e5d49072249e94 (patch)
tree48eb2e95d18c9d1fbdfcd0864ca09a6e64d79f5a /tools/format.py
parent6c79b471aa5cf2c87d237015f5dacc5a7ed03b67 (diff)
Clean up tools/
- Factor out tools/util.py - Move js/*.py to tools. - Rewrite tools/format.sh in python. - Run lint first in travis.
Diffstat (limited to 'tools/format.py')
-rwxr-xr-xtools/format.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/format.py b/tools/format.py
new file mode 100755
index 000000000..d1f555e5d
--- /dev/null
+++ b/tools/format.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import os
+from glob import glob
+from util import run
+
+root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+os.chdir(root_path)
+# TODO(ry) Install clang-format in third_party.
+run(["clang-format", "-i", "-style", "Google"] + glob("src/*.cc") +
+ glob("src/*.h"))
+for fn in ["BUILD.gn", ".gn"] + glob("build_extra/**/*.gn*"):
+ run(["gn", "format", fn])
+# TODO(ry) Install yapf in third_party.
+run(["yapf", "-i"] + glob("tools/*.py"))
+# TODO(ry) Install prettier in third_party.
+run([
+ "prettier", "--write", "js/deno.d.ts", "js/main.ts", "js/mock_runtime.js",
+ "tsconfig.json"
+])
+# Do not format these.
+# js/msg_generated.ts
+# js/flatbuffers.js
+run(["rustfmt", "--write-mode", "overwrite"] + glob("src/*.rs"))