|
2 | 2 |
|
3 | 3 | import { existsSync } from "node:fs"; |
4 | 4 | import Path from "node:path"; |
5 | | -import { execFile } from "node:child_process"; |
6 | | -import { promisify } from "node:util"; |
7 | 5 | import { promiseErrorToSettled } from "./utils.js"; |
8 | 6 | import { |
9 | 7 | readWorkspaceDirs, |
10 | 8 | readWorkspaceSettings, |
11 | 9 | resolveWorkspaceDeps, |
12 | 10 | } from "./pnpmWorkspace.js"; |
13 | | -const execFileAsync = promisify(execFile); |
| 11 | +import { compare } from "./git.js"; |
14 | 12 |
|
15 | 13 | const cwd = process.cwd(); |
16 | 14 |
|
| 15 | +const [_node, _bin, gitFromPointer = "HEAD^", gitToPointer = "HEAD"] = |
| 16 | + process.argv; |
| 17 | + |
17 | 18 | const rootDir = cwd |
18 | 19 | .split(Path.sep) |
19 | 20 | .map((_, idx) => Path.join(cwd, "../".repeat(idx))) |
@@ -41,28 +42,30 @@ const result = await Promise.all([ |
41 | 42 | ...workspaceDepsRelativePaths.map(async (path) => { |
42 | 43 | return { |
43 | 44 | result: await promiseErrorToSettled( |
44 | | - execFileAsync(`git`, [`diff`, `HEAD^`, `HEAD`, `--quiet`, path]), |
| 45 | + compare({ |
| 46 | + from: gitFromPointer, |
| 47 | + to: gitToPointer, |
| 48 | + paths: [path], |
| 49 | + pathsToIgnore: [], |
| 50 | + }), |
45 | 51 | ), |
46 | 52 | path, |
47 | 53 | }; |
48 | 54 | }), |
49 | 55 | (async () => { |
50 | | - const pathsToIgnore = (await readWorkspaceDirs({ rootDir, cwd })) |
51 | | - .map((path) => Path.relative(cwd, path)) |
52 | | - .map((path) => `:^${path}`); |
| 56 | + const pathsToIgnore = (await readWorkspaceDirs({ rootDir, cwd })).map( |
| 57 | + (path) => Path.relative(cwd, path), |
| 58 | + ); |
53 | 59 | const relativeRoot = Path.relative(cwd, rootDir); |
54 | 60 |
|
55 | 61 | return { |
56 | 62 | result: await promiseErrorToSettled( |
57 | | - execFileAsync(`git`, [ |
58 | | - `diff`, |
59 | | - `HEAD^`, |
60 | | - `HEAD`, |
61 | | - `--quiet`, |
62 | | - `--`, |
63 | | - relativeRoot, |
64 | | - ...pathsToIgnore, |
65 | | - ]), |
| 63 | + compare({ |
| 64 | + from: gitFromPointer, |
| 65 | + to: gitToPointer, |
| 66 | + paths: [relativeRoot], |
| 67 | + pathsToIgnore, |
| 68 | + }), |
66 | 69 | ), |
67 | 70 | path: relativeRoot, |
68 | 71 | }; |
|
0 commit comments