summaryrefslogtreecommitdiff
path: root/tools/util.js
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2022-05-18 22:00:11 +0200
committerGitHub <noreply@github.com>2022-05-18 22:00:11 +0200
commit4e1ca1d1787f25ab9f0a72ccf9d8028f70b3a7ed (patch)
tree2d0062ec1dd864c7ed98301119ac5f1c133f844a /tools/util.js
parent5ad8919d642b646caa3328930dd1a3f290bc587e (diff)
refactor: use spawn API across codebase (#14414)
Diffstat (limited to 'tools/util.js')
-rw-r--r--tools/util.js19
1 files changed, 7 insertions, 12 deletions
diff --git a/tools/util.js b/tools/util.js
index fa62097d4..c76456b9a 100644
--- a/tools/util.js
+++ b/tools/util.js
@@ -8,24 +8,21 @@ import {
} from "../test_util/std/path/mod.ts";
export { dirname, fromFileUrl, join, resolve, toFileUrl };
export { existsSync, walk } from "../test_util/std/fs/mod.ts";
-export { readLines } from "../test_util/std/io/mod.ts";
+export { TextLineStream } from "../test_util/std/streams/delimiter.ts";
export { delay } from "../test_util/std/async/delay.ts";
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
-async function getFilesFromGit(baseDir, cmd) {
- const p = Deno.run({
- cmd,
- stdout: "piped",
+async function getFilesFromGit(baseDir, args) {
+ const { status, stdout } = await Deno.spawn("git", {
+ stderr: "inherit",
+ args,
});
- const output = new TextDecoder().decode(await p.output());
- const { success } = await p.status();
- if (!success) {
+ const output = new TextDecoder().decode(stdout);
+ if (!status.success) {
throw new Error("gitLsFiles failed");
}
- p.close();
-
const files = output.split("\0").filter((line) => line.length > 0).map(
(filePath) => {
return Deno.realPathSync(join(baseDir, filePath));
@@ -38,7 +35,6 @@ async function getFilesFromGit(baseDir, cmd) {
function gitLsFiles(baseDir, patterns) {
baseDir = Deno.realPathSync(baseDir);
const cmd = [
- "git",
"-C",
baseDir,
"ls-files",
@@ -57,7 +53,6 @@ function gitLsFiles(baseDir, patterns) {
function gitStaged(baseDir, patterns) {
baseDir = Deno.realPathSync(baseDir);
const cmd = [
- "git",
"-C",
baseDir,
"diff",