Skip to content

Commit 657d011

Browse files
authored
Dont use unreliable inodes for checking file identity (#25008)
* Dont use unreliable inode as unique identifier * Just concat with `\n * Introduce path-overriding code to allow local executables ot be found
1 parent f597589 commit 657d011

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Jakefile.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ const ts = require("./lib/typescript");
1010
const del = require("del");
1111
const getDirSize = require("./scripts/build/getDirSize");
1212

13+
// add node_modules to path so we don't need global modules, prefer the modules by adding them first
14+
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
15+
if (process.env.path !== undefined) {
16+
process.env.path = nodeModulesPathPrefix + process.env.path;
17+
}
18+
else if (process.env.PATH !== undefined) {
19+
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
20+
}
21+
1322
const host = process.env.TYPESCRIPT_HOST || process.env.host || "node";
1423

1524
const locales = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"];

scripts/build/getDirSize.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@ const { join } = require("path");
44

55
/**
66
* Find the size of a directory recursively.
7-
* Symbolic links are counted once (same inode).
7+
* Symbolic links can cause a loop.
88
* @param {string} root
9-
* @param {Set} seen
109
* @returns {number} bytes
1110
*/
12-
function getDirSize(root, seen = new Set()) {
11+
function getDirSize(root) {
1312
const stats = lstatSync(root);
1413

15-
if (seen.has(stats.ino)) {
16-
return 0;
17-
}
18-
19-
seen.add(stats.ino);
20-
2114
if (!stats.isDirectory()) {
2215
return stats.size;
2316
}
2417

2518
return readdirSync(root)
26-
.map(file => getDirSize(join(root, file), seen))
19+
.map(file => getDirSize(join(root, file)))
2720
.reduce((acc, num) => acc + num, 0);
2821
}
2922

scripts/produceLKG.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function writeGitAttributes() {
7575

7676
async function copyWithCopyright(fileName: string) {
7777
const content = await fs.readFile(path.join(source, fileName), "utf-8");
78-
await fs.writeFile(path.join(dest, fileName), copyright + "\r\n" + content);
78+
await fs.writeFile(path.join(dest, fileName), copyright + "\n" + content);
7979
}
8080

8181
async function copyFromBuiltLocal(fileName: string) {

0 commit comments

Comments
 (0)