diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2019-01-18 05:09:44 +0900 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-01-17 15:09:44 -0500 |
commit | f19622e7681b7753788137706e535f72c3ebb38e (patch) | |
tree | 0cd5261230f895359ca479d2b2234a56f137e924 /tools/test_format.py | |
parent | befc6b2e7650af09f81562cd306a6f5d3f46dc21 (diff) |
Rewrite tools/format.py in deno (#1528)
Note: findFiles and findFilesWalk are borrowed from the previous
attempt of @pseudo-su (#1434)
Diffstat (limited to 'tools/test_format.py')
-rwxr-xr-x | tools/test_format.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/test_format.py b/tools/test_format.py index a0d5ba08e..69c050501 100755 --- a/tools/test_format.py +++ b/tools/test_format.py @@ -1,18 +1,40 @@ #!/usr/bin/env python -# This program fails if ./tools/format.py changes any files. +# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +# This program fails if ./tools/format.ts changes any files. +import os import sys import util import sys import subprocess +from distutils.spawn import find_executable + + +def lookup_deno_path(): + deno_exe = "deno" + util.executable_suffix + release_deno = os.path.join(util.root_path, "target", "release", deno_exe) + debug_deno = os.path.join(util.root_path, "target", "debug", deno_exe) + + if os.path.exists(release_deno): + return release_deno + if os.path.exists(debug_deno): + return debug_deno + + return find_executable("deno") def main(): - util.run([sys.executable, "tools/format.py"]) + deno_path = lookup_deno_path() + + if not deno_path: + print "No available deno executable." + sys.exit(1) + + util.run([deno_path, "--allow-run", "tools/format.ts"]) output = util.run_output( ["git", "status", "-uno", "--porcelain", "--ignore-submodules"]) if len(output) > 0: - print "Run tools/format.py " + print "Run tools/format.ts " print output sys.exit(1) |