diff options
Diffstat (limited to 'Scripts')
| -rw-r--r-- | Scripts/main.js | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/Scripts/main.js b/Scripts/main.js index 70af784..0155d80 100644 --- a/Scripts/main.js +++ b/Scripts/main.js @@ -92,22 +92,13 @@ function normalizeArray(value) { .filter((entry) => entry.length > 0); } -function resolveWorkspaceRelativePath(path) { - if (!path) { - return null; - } - - if (path.startsWith("/")) { - return path; - } - - if (nova.workspace.path) { - return nova.path.join(nova.workspace.path, path); - } - - return path; -} - +/** + * Resolve a relative path to an absolute path, using a provided base directory + * or workspace root as fallback + * + * @param {string} path - Relative path + * @param {string|null} base - Base path or null to use the workspace as base + */ function resolvePathAgainstBase(path, base) { if (!path) { return null; @@ -121,7 +112,11 @@ function resolvePathAgainstBase(path, base) { return nova.path.join(base, path); } - return resolveWorkspaceRelativePath(path); + if (nova.workspace.path) { + return nova.path.join(nova.workspace.path, path); + } + + return path; } function getTaskConfigValue(config, key) { @@ -140,7 +135,7 @@ function getTaskArgs(config, key) { function getTaskCwd(config) { const configured = getTaskConfigValue(config, "cwd"); if (configured) { - return resolveWorkspaceRelativePath(configured); + return resolvePathAgainstBase(configured, null); } return nova.workspace.path || null; |
