diff --git a/__test__/assets/binary.spec.js b/__test__/assets/binary.spec.js index 7381642..6355d2c 100644 --- a/__test__/assets/binary.spec.js +++ b/__test__/assets/binary.spec.js @@ -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')); }); }); diff --git a/src/assets/binary.js b/src/assets/binary.js index 9f8063a..fc0ac2d 100644 --- a/src/assets/binary.js +++ b/src/assets/binary.js @@ -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));