Skip to content

Commit cee73fd

Browse files
committed
Fix binary installation and update version
1 parent 1339e1a commit cee73fd

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

index.cjs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,33 @@ const buildDownloadBinaryUrl = (version) => {
6060
}
6161

6262
async function installBinary() {
63-
const packageVersion = require('./package.json').version;
64-
const cliVersion = getExpectedCliVersion
63+
const cliVersion = getExpectedCliVersion();
64+
if (fs.existsSync(binaryPath)) {
65+
console.log('Removing existing binary...');
66+
fs.unlinkSync(binaryPath);
67+
}
6568
const downloadUrl = buildDownloadBinaryUrl(cliVersion);
6669
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
6770
fs.mkdirSync(path.join(__dirname, 'bin'));
6871
}
6972

70-
const response = await axios({
71-
url: downloadUrl,
72-
method: 'GET',
73-
responseType: 'stream'
74-
});
75-
76-
const writer = fs.createWriteStream(binaryPath);
77-
response.data.pipe(writer);
78-
await new Promise((resolve, reject) => {
79-
writer.on('finish', resolve);
80-
writer.on('error', reject);
81-
});
73+
try {
74+
const response = await axios({
75+
url: downloadUrl,
76+
method: 'GET',
77+
responseType: 'stream'
78+
});
79+
80+
const writer = fs.createWriteStream(binaryPath);
81+
response.data.pipe(writer);
82+
await new Promise((resolve, reject) => {
83+
writer.on('finish', resolve);
84+
writer.on('error', reject);
85+
});
86+
} catch (error) {
87+
console.error('Error downloading SimpleLocalize CLI binary:', error.message);
88+
process.exit(1);
89+
}
8290

8391
// Make it executable (only on Unix-based systems)
8492
if (os.platform() !== 'win32') {
@@ -94,7 +102,7 @@ async function installBinary() {
94102

95103
const linkToNodeModulesBin = () => {
96104
let nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');
97-
105+
98106
if (os.platform() === 'win32') {
99107
nodeModulesBinPath += '.exe';
100108
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@simplelocalize/cli",
3-
"version": "2.9.2",
3+
"version": "2.9.3",
44
"description": "SimpleLocalize CLI for NPM",
55
"main": "index.cjs",
66
"type": "module",

0 commit comments

Comments
 (0)