summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2020-07-14 15:24:17 -0400
committerGitHub <noreply@github.com>2020-07-14 15:24:17 -0400
commitcde4dbb35132848ffece59ef9cfaccff32347124 (patch)
treecc7830968c6decde704c8cfb83c9185193dc698f /tools
parent9eca71caa1674c31f9cc5d4e86c03f10b59e0a00 (diff)
Use dprint for internal formatting (#6682)
Diffstat (limited to 'tools')
-rw-r--r--tools/README.md4
-rw-r--r--tools/deno_tcp.ts2
-rwxr-xr-xtools/format.py25
-rw-r--r--tools/node_tcp.js2
-rw-r--r--tools/node_tcp_promise.js2
-rw-r--r--tools/node_tcp_proxy.js2
-rw-r--r--tools/package.json2
7 files changed, 14 insertions, 25 deletions
diff --git a/tools/README.md b/tools/README.md
index cec1e39e8..5f3a8c476 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -4,8 +4,8 @@ Documentation for various tooling in support of Deno development
## format.py
-This script will format the code (currently using prettier, yapf and rustfmt).
-It is a prerequisite to run this before code check in.
+This script will format the code (currently using dprint, yapf and rustfmt). It
+is a prerequisite to run this before code check in.
To run formatting:
diff --git a/tools/deno_tcp.ts b/tools/deno_tcp.ts
index 06907db90..898869768 100644
--- a/tools/deno_tcp.ts
+++ b/tools/deno_tcp.ts
@@ -6,7 +6,7 @@ const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) });
const response = new TextEncoder().encode(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n"
+ "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
);
async function handle(conn: Deno.Conn): Promise<void> {
const buffer = new Uint8Array(1024);
diff --git a/tools/format.py b/tools/format.py
index 2f3faf0dd..4ff17af43 100755
--- a/tools/format.py
+++ b/tools/format.py
@@ -3,7 +3,7 @@
import os
import sys
import argparse
-from third_party import python_env
+from third_party import python_env, get_prebuilt_tool_path
from util import git_ls_files, git_staged, third_party_path, root_path
from util import print_command, run
@@ -17,7 +17,7 @@ def get_cmd_args():
return cmd_args
parser = argparse.ArgumentParser()
- parser.add_argument("--js", help="run prettier", action="store_true")
+ parser.add_argument("--js", help="run dprint", action="store_true")
parser.add_argument("--py", help="run yapf", action="store_true")
parser.add_argument("--rs", help="run rustfmt", action="store_true")
parser.add_argument(
@@ -38,7 +38,7 @@ def main():
did_fmt = False
if args.js:
- prettier()
+ dprint()
did_fmt = True
if args.py:
yapf()
@@ -48,24 +48,15 @@ def main():
did_fmt = True
if not did_fmt:
- prettier()
+ dprint()
yapf()
rustfmt()
-def prettier():
- script = os.path.join(third_party_path, "node_modules", "prettier",
- "bin-prettier.js")
- source_files = get_sources(root_path, ["*.js", "*.json", "*.ts", "*.md"])
- if source_files:
- max_command_length = 24000
- while len(source_files) > 0:
- command = ["node", script, "--write", "--loglevel=error", "--"]
- while len(source_files) > 0:
- command.append(source_files.pop())
- if len(" ".join(command)) > max_command_length:
- break
- run(command, shell=False, quiet=True)
+def dprint():
+ executable_path = get_prebuilt_tool_path("dprint")
+ command = [executable_path, "fmt"]
+ run(command, shell=False, quiet=True)
def yapf():
diff --git a/tools/node_tcp.js b/tools/node_tcp.js
index 7c6147dbf..22e2a5161 100644
--- a/tools/node_tcp.js
+++ b/tools/node_tcp.js
@@ -5,7 +5,7 @@ const port = process.argv[2] || "4544";
console.log("port", port);
const response = Buffer.from(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n"
+ "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
);
Server((socket) => {
diff --git a/tools/node_tcp_promise.js b/tools/node_tcp_promise.js
index c59a9a7b4..36709d2b9 100644
--- a/tools/node_tcp_promise.js
+++ b/tools/node_tcp_promise.js
@@ -5,7 +5,7 @@ const port = process.argv[2] || "4544";
console.log("port", port);
const response = Buffer.from(
- "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n"
+ "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
);
function write(socket, buffer) {
diff --git a/tools/node_tcp_proxy.js b/tools/node_tcp_proxy.js
index 304ed0407..d693dc5c8 100644
--- a/tools/node_tcp_proxy.js
+++ b/tools/node_tcp_proxy.js
@@ -64,5 +64,5 @@ console.log(
"redirecting connections from 127.0.0.1:%d to %s:%d",
localport,
remotehost,
- remoteport
+ remoteport,
);
diff --git a/tools/package.json b/tools/package.json
index 56e056b6a..bd619fa56 100644
--- a/tools/package.json
+++ b/tools/package.json
@@ -2,13 +2,11 @@
"name": "deno",
"private": true,
"devDependencies": {
- "@types/prettier": "1.16.1",
"@typescript-eslint/eslint-plugin": "2.5.0",
"@typescript-eslint/parser": "2.5.0",
"eslint": "5.15.1",
"eslint-config-prettier": "4.1.0",
"magic-string": "0.25.2",
- "prettier": "1.17.1",
"typescript": "3.6.3"
}
}