mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
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
This commit is contained in:
@@ -4,26 +4,19 @@ const { join } = require("path");
|
||||
|
||||
/**
|
||||
* Find the size of a directory recursively.
|
||||
* Symbolic links are counted once (same inode).
|
||||
* Symbolic links can cause a loop.
|
||||
* @param {string} root
|
||||
* @param {Set} seen
|
||||
* @returns {number} bytes
|
||||
*/
|
||||
function getDirSize(root, seen = new Set()) {
|
||||
function getDirSize(root) {
|
||||
const stats = lstatSync(root);
|
||||
|
||||
if (seen.has(stats.ino)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
seen.add(stats.ino);
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
return stats.size;
|
||||
}
|
||||
|
||||
return readdirSync(root)
|
||||
.map(file => getDirSize(join(root, file), seen))
|
||||
.map(file => getDirSize(join(root, file)))
|
||||
.reduce((acc, num) => acc + num, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ async function writeGitAttributes() {
|
||||
|
||||
async function copyWithCopyright(fileName: string) {
|
||||
const content = await fs.readFile(path.join(source, fileName), "utf-8");
|
||||
await fs.writeFile(path.join(dest, fileName), copyright + "\r\n" + content);
|
||||
await fs.writeFile(path.join(dest, fileName), copyright + "\n" + content);
|
||||
}
|
||||
|
||||
async function copyFromBuiltLocal(fileName: string) {
|
||||
|
||||
Reference in New Issue
Block a user