Merge pull request #4 from alecmocatta/exdev-fix

Fix error "EXDEV: cross-device link not permitted"
This commit is contained in:
Guido Zuidhof
2022-06-30 13:21:27 +02:00
committed by GitHub
2 changed files with 4 additions and 3 deletions

View File

@@ -47,6 +47,6 @@ describe('verifyAndPlaceBinary()', () => {
verifyAndPlaceBinary('command', './bin', callback);
expect(fs.renameSync).toHaveBeenCalledWith(path.join('bin', 'command'), path.sep + path.join('usr', 'local', 'bin', 'command'));
expect(fs.copyFileSync).toHaveBeenCalledWith(path.join('bin', 'command'), path.sep + path.join('usr', 'local', 'bin', 'command'));
});
});

View File

@@ -1,5 +1,5 @@
const { join } = require('path');
const { existsSync, renameSync, chmodSync } = require('fs');
const { chmodSync, copyFileSync, existsSync, unlink } = require('fs');
const { getInstallationPath } = require('../common');
function verifyAndPlaceBinary(binName, binPath, callback) {
@@ -13,7 +13,8 @@ function verifyAndPlaceBinary(binName, binPath, callback) {
}
// Move the binary file and make sure it is executable
renameSync(join(binPath, binName), join(installationPath, binName));
copyFileSync(join(binPath, binName), join(installationPath, binName));
unlink(join(binPath, binName));
chmodSync(join(installationPath, binName), '755');
console.log('Placed binary on', join(installationPath, binName));