Skip to content

Commit 549247d

Browse files
committed
fix: use relative paths in the build manifest
1 parent 925675e commit 549247d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/build.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ Build Type: ${config.buildType}
154154
manifest = JSON.parse(manifestContent)
155155
}
156156
// add the new entry to the manifest
157-
manifest[JSON.stringify(config)] = relative(config.targetDirectory, addonPath)
157+
manifest[serializeConfig(config, config.packageDirectory)] = relative(config.targetDirectory, addonPath)
158158
await writeFile(manifestPath, JSON.stringify(manifest, null, 2))
159159
}
160+
161+
function serializeConfig(config: BuildConfiguration, rootDir: string) {
162+
// replace absolute paths with relative paths
163+
const serialized = JSON.stringify(config, (_key, value) => {
164+
if (typeof value === "string" && value.startsWith(rootDir)) {
165+
return relative(rootDir, value)
166+
}
167+
return value
168+
})
169+
170+
return serialized
171+
}

test/zeromq.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ suite("zeromq", { timeout: 300_000 }, async () => {
5959
runtime: "node",
6060
runtimeVersion: process.versions.node,
6161
buildType: "Release",
62-
packageDirectory: zeromqPath,
62+
packageDirectory: "",
6363
projectName: "addon",
6464
nodeAPI: "node-addon-api",
65-
targetDirectory: await realpath(join(zeromqPath, "build")),
66-
stagingDirectory: await realpath(join(zeromqPath, "staging")),
65+
targetDirectory: "build",
66+
stagingDirectory: "staging",
6767
cmakeToUse: await which("cmake"),
6868
generatorToUse: "Ninja",
6969
generatorBinary: await which("ninja"),

0 commit comments

Comments
 (0)