INNER CODE UNIT · TypeScript
findWorkspaceRoot
tradingview/lightweight-charts · packages/create-lwc-plugin/src/index.ts:13
function findWorkspaceRoot(from: string): string | null {
let current = from;
for (;;) {
if (fs.existsSync(path.join(current, WORKSPACE_MARKER))) return current;
const parent = path.dirname(current);
if (parent === current) return null;
current = parent;
}
}
async function init() {
console.log();
intro(color.inverse(' create-lwc-plugin '));
const workspaceRequested = process.argv.includes('--workspace');
let workspaceRoot: string | null = null;
if (workspaceRequested) {
workspaceRoot = findWorkspaceRoot(cwd);