aboutsummaryrefslogtreecommitdiff
path: root/Scripts/main.js
diff options
context:
space:
mode:
authorDavid Czihak <git@dcz.at>2026-05-08 17:36:44 +0200
committerDavid Czihak <git@dcz.at>2026-05-08 17:36:44 +0200
commit62b02215b930cae4a45058e95e627352223499a0 (patch)
tree2a9961b9fb2901f194550bbcc85da5b449f2abeb /Scripts/main.js
parentd0436c0121254380e24cf4c99a61472377195d65 (diff)
Refactor: Merge two path resolutiion functions
`resolveWorkspaceRelativePath` is merged into `resolvePathAgainstBase` by passing `null` as the second argument.
Diffstat (limited to 'Scripts/main.js')
-rw-r--r--Scripts/main.js31
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;