Skip to content

Commit 1e6b873

Browse files
committed
address comments
1 parent 8820d3a commit 1e6b873

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

scripts/check-redirects-on-rename.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import {execSync} from 'child_process';
2+
import {execFileSync} from 'child_process';
33
import fs from 'fs';
44
import path from 'path';
55

@@ -66,10 +66,13 @@ function detectRenamedFiles(): RenamedFile[] {
6666
const headSha = process.env.GITHUB_SHA || 'HEAD';
6767

6868
// Use git diff to find renames (similarity threshold of 50%)
69-
const diffOutput = execSync(
70-
`git diff --find-renames=50% --name-status ${baseSha}...${headSha}`,
69+
const diffOutput = execFileSync(
70+
'git',
71+
['diff', '--find-renames=50%', '--name-status', `${baseSha}...${headSha}`],
7172
{encoding: 'utf8', stdio: 'pipe'}
72-
).trim();
73+
)
74+
.toString()
75+
.trim();
7376

7477
const renamedFiles: RenamedFile[] = [];
7578

@@ -323,10 +326,16 @@ function validateRedirects(): MissingRedirect[] {
323326

324327
try {
325328
// Check if redirects.js was modified in this PR
326-
const modifiedFiles = execSync(`git diff --name-only ${baseSha}...${headSha}`, {
327-
encoding: 'utf8',
328-
stdio: 'pipe',
329-
}).trim();
329+
const modifiedFiles = execFileSync(
330+
'git',
331+
['diff', '--name-only', `${baseSha}...${headSha}`],
332+
{
333+
encoding: 'utf8',
334+
stdio: 'pipe',
335+
}
336+
)
337+
.toString()
338+
.trim();
330339

331340
const redirectsModified = modifiedFiles.includes('redirects.js');
332341

@@ -336,7 +345,7 @@ function validateRedirects(): MissingRedirect[] {
336345
} else {
337346
// Try to get base version for comparison
338347
try {
339-
const baseRedirects = execSync(`git show ${baseSha}:redirects.js`, {
348+
const baseRedirects = execFileSync('git', ['show', `${baseSha}:redirects.js`], {
340349
encoding: 'utf8',
341350
stdio: 'pipe',
342351
});

0 commit comments

Comments
 (0)