temp
This commit is contained in:
13
src/tools/utils.ts
Normal file
13
src/tools/utils.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as path from 'path';
|
||||
|
||||
/** Directory names to skip when walking or listing workspaces. */
|
||||
export const EXCLUDED = new Set(['node_modules', '.git', 'dist', 'build', 'lib', '.cache', 'coverage']);
|
||||
|
||||
/** Resolve a relative path safely within a workspace root — throws if it tries to escape. */
|
||||
export function safeResolve(root: string, rel: string): string {
|
||||
const resolved = path.resolve(root, rel);
|
||||
if (!resolved.startsWith(path.resolve(root))) {
|
||||
throw new Error(`Path escapes workspace: ${rel}`);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
Reference in New Issue
Block a user