fix: installer relative path issue for npx resolved
This commit is contained in:
@@ -23,13 +23,24 @@ class Installer {
|
|||||||
const spinner = ora("Analyzing installation directory...").start();
|
const spinner = ora("Analyzing installation directory...").start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Resolve installation directory
|
// Store the original CWD where npx was executed
|
||||||
let installDir = path.resolve(config.directory);
|
const originalCwd = process.env.INIT_CWD || process.env.PWD || process.cwd();
|
||||||
|
|
||||||
|
// Resolve installation directory relative to where the user ran the command
|
||||||
|
let installDir = path.isAbsolute(config.directory)
|
||||||
|
? config.directory
|
||||||
|
: path.resolve(originalCwd, config.directory);
|
||||||
|
|
||||||
if (path.basename(installDir) === '.bmad-core') {
|
if (path.basename(installDir) === '.bmad-core') {
|
||||||
// If user points directly to .bmad-core, treat its parent as the project root
|
// If user points directly to .bmad-core, treat its parent as the project root
|
||||||
installDir = path.dirname(installDir);
|
installDir = path.dirname(installDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log resolved path for clarity
|
||||||
|
if (!path.isAbsolute(config.directory)) {
|
||||||
|
spinner.text = `Resolving "${config.directory}" to: ${installDir}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if directory exists and handle non-existent directories
|
// Check if directory exists and handle non-existent directories
|
||||||
if (!(await fileManager.pathExists(installDir))) {
|
if (!(await fileManager.pathExists(installDir))) {
|
||||||
spinner.stop();
|
spinner.stop();
|
||||||
@@ -74,6 +85,7 @@ class Installer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
// Preserve the original CWD for the recursive call
|
||||||
config.directory = newDirectory;
|
config.directory = newDirectory;
|
||||||
return await this.install(config); // Recursive call with new directory
|
return await this.install(config); // Recursive call with new directory
|
||||||
} else if (action === 'create') {
|
} else if (action === 'create') {
|
||||||
|
|||||||
Reference in New Issue
Block a user