fix: bug in utils path
add an optional arg to create config path
This commit is contained in:
@@ -11,19 +11,25 @@ export function resolvePath(raw: string): string {
|
||||
return resolve(raw);
|
||||
}
|
||||
|
||||
export function ensureWorkspace(rawPath: string): string {
|
||||
export function ensureWorkspace(rawPath: string, createIfMissing = true): string {
|
||||
const path = resolvePath(rawPath);
|
||||
if (!existsSync(path)) {
|
||||
if (createIfMissing) {
|
||||
mkdirSync(path, { recursive: true });
|
||||
} else {
|
||||
throw new Error(
|
||||
`Workspace does not exist: ${path}\nRun 'nanobot onboard' to initialize.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
export function syncTemplates(workspacePath: string): string[] {
|
||||
// Get project root relative to this file
|
||||
// Get project root relative to this file (src/cli/utils.ts)
|
||||
const currentFile = fileURLToPath(import.meta.url);
|
||||
const srcDir = dirname(currentFile);
|
||||
const projectRoot = resolve(srcDir, '..');
|
||||
const projectRoot = resolve(srcDir, '..', '..');
|
||||
const templatesDir = resolve(projectRoot, 'templates');
|
||||
|
||||
if (!existsSync(templatesDir)) {
|
||||
|
||||
Reference in New Issue
Block a user