Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,33 @@ const buildDownloadBinaryUrl = (version) => {
}

async function installBinary() {
const packageVersion = require('./package.json').version;
const cliVersion = getExpectedCliVersion
const cliVersion = getExpectedCliVersion();
if (fs.existsSync(binaryPath)) {
console.log('Removing existing binary...');
fs.unlinkSync(binaryPath);
}
const downloadUrl = buildDownloadBinaryUrl(cliVersion);
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
fs.mkdirSync(path.join(__dirname, 'bin'));
}

const response = await axios({
url: downloadUrl,
method: 'GET',
responseType: 'stream'
});

const writer = fs.createWriteStream(binaryPath);
response.data.pipe(writer);
await new Promise((resolve, reject) => {
writer.on('finish', resolve);
writer.on('error', reject);
});
try {
const response = await axios({
url: downloadUrl,
method: 'GET',
responseType: 'stream'
});

const writer = fs.createWriteStream(binaryPath);
response.data.pipe(writer);
await new Promise((resolve, reject) => {
writer.on('finish', resolve);
writer.on('error', reject);
});
} catch (error) {
console.error('Error downloading SimpleLocalize CLI binary:', error.message);
process.exit(1);
}

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

const linkToNodeModulesBin = () => {
let nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');

if (os.platform() === 'win32') {
nodeModulesBinPath += '.exe';
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simplelocalize/cli",
"version": "2.9.2",
"version": "2.9.3",
"description": "SimpleLocalize CLI for NPM",
"main": "index.cjs",
"type": "module",
Expand Down