Commit ffd86f2a by Will Browne Committed by GitHub

Plugins: Force POSIX style path separators for manifest generation (#30287)

* force POSIX style path separators

* include posix style for symbolic links

* include in error string
parent 2638a433
......@@ -7,19 +7,22 @@ const MANIFEST_FILE = 'MANIFEST.txt';
async function* walk(dir: string, baseDir: string): AsyncGenerator<string, any, any> {
for await (const d of await (fs.promises as any).opendir(dir)) {
const entry = path.join(dir, d.name);
const entry = path.posix.join(dir, d.name);
if (d.isDirectory()) {
yield* await walk(entry, baseDir);
} else if (d.isFile()) {
yield path.relative(baseDir, entry);
yield path.posix.relative(baseDir, entry);
} else if (d.isSymbolicLink()) {
const realPath = fs.realpathSync(entry);
if (!realPath.startsWith(baseDir)) {
throw new Error(
`symbolic link ${path.relative(baseDir, entry)} targets a file outside of the base directory: ${baseDir}`
`symbolic link ${path.posix.relative(
baseDir,
entry
)} targets a file outside of the base directory: ${baseDir}`
);
}
yield path.relative(baseDir, entry);
yield path.posix.relative(baseDir, entry);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment