fix "EXDEV: cross-device link not permitted, rename 'bin\starlit.exe' ->

'C:\npm\prefix\bin\starlit.exe'"
This commit is contained in:
alecmocatta
2022-06-16 12:44:34 +01:00
parent 87e2c92559
commit c8160d6ee1
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));