fix: resolve relative paths in --index flag to prevent malformed config paths
When using --index with relative paths like './index/my-project', the path was stored directly as the config filename, resulting in paths like: /home/user/.config/qmd/./index/my-project.yml This caused 'no such file or directory' errors. Now relative paths are resolved and normalized by replacing path separators with underscores.
This commit is contained in:
parent
640ac13cd0
commit
00bcfbbd34
@ -58,7 +58,16 @@ let currentIndexName: string = "index";
|
||||
* Config file will be ~/.config/qmd/{indexName}.yml
|
||||
*/
|
||||
export function setConfigIndexName(name: string): void {
|
||||
currentIndexName = name;
|
||||
// Resolve relative paths to absolute paths and sanitize for use as filename
|
||||
if (name.includes('/')) {
|
||||
const { resolve } = require('path');
|
||||
const { cwd } = require('process');
|
||||
const absolutePath = resolve(cwd(), name);
|
||||
// Replace path separators with underscores to create a valid filename
|
||||
currentIndexName = absolutePath.replace(/\//g, '_').replace(/^_/, '');
|
||||
} else {
|
||||
currentIndexName = name;
|
||||
}
|
||||
}
|
||||
|
||||
function getConfigDir(): string {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user