fix: invalid cross-device link (#54)

* fix: invalid cross-device link

* version flag fix in workflow

* remove version from package.json
This commit is contained in:
Sahil Bansal
2025-07-04 20:56:31 +05:30
committed by GitHub
parent 74248cd74a
commit 49b2371cc3
2 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -93,5 +93,5 @@ jobs:
- name: Test installation
run: |
npm install -g @safedep/pmg@${{ steps.version.outputs.version }}
pmg --version
pmg version
pmg --help || true
+12 -2
View File
@@ -192,8 +192,18 @@ async function install() {
);
}
// Move binary to final location
fs.renameSync(extractedBinaryPath, finalBinaryPath);
// Move binary to final location (handle cross-device links)
try {
fs.renameSync(extractedBinaryPath, finalBinaryPath);
} catch (error) {
if (error.code === "EXDEV") {
// Cross-device link not permitted, copy and delete instead
fs.copyFileSync(extractedBinaryPath, finalBinaryPath);
fs.unlinkSync(extractedBinaryPath);
} else {
throw error;
}
}
// Make executable on Unix systems
if (process.platform !== "win32") {