Skip to content

Commit 759eb9a

Browse files
committed
Add macOS support
1 parent 49625ab commit 759eb9a

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

index.js renamed to index.cjs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ const buildDownloadBinaryUrl = (version) => {
4545
if (os.arch() === "arm64") {
4646
arch = "-arm64"
4747
}
48+
console.log(`Downloading SimpleLocalize CLI ${version} for ${platform}${arch}...`);
4849
return `https://github.com/simplelocalize/simplelocalize-cli/releases/download/${version}/simplelocalize-cli-${platform}${arch}`
4950
}
5051

51-
async function installBinary(version = "2.8.0") {
52-
const downloadUrl = buildDownloadBinaryUrl(version);
52+
async function installBinary() {
53+
const cliVersion = "2.8.0";
54+
const downloadUrl = buildDownloadBinaryUrl(cliVersion);
5355
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
5456
fs.mkdirSync(path.join(__dirname, 'bin'));
5557
}
56-
console.log(`Downloading ${downloadUrl}...`);
58+
5759
const response = await axios({
5860
url: downloadUrl,
5961
method: 'GET',
@@ -77,6 +79,15 @@ async function installBinary(version = "2.8.0") {
7779
console.log('Binary is now executable.');
7880
}
7981

82+
const linkToNodeModulesBin = () => {
83+
const nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');
84+
if (fs.existsSync(nodeModulesBinPath)) {
85+
fs.unlinkSync(nodeModulesBinPath);
86+
}
87+
fs.symlinkSync(binaryPath, nodeModulesBinPath);
88+
console.log('Link to node_modules/.bin created.');
89+
}
90+
8091
const init = async () => {
8192
console.log("Checking if SimpleLocalize CLI is installed...");
8293
if (!isBinaryInstalled()) {
@@ -91,7 +102,8 @@ const init = async () => {
91102
console.log("SimpleLocalize CLI already installed.");
92103
}
93104
printBinaryVersion();
105+
linkToNodeModulesBin();
94106
process.exit(0);
95107
}
96108

97-
await init();
109+
init();

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
2-
"name": "simplelocalize",
3-
"version": "1.0.0",
2+
"name": "@simplelocalize/cli",
3+
"version": "1.0.6",
44
"description": "SimpleLocalize CLI for NPM",
5-
"main": "index.js",
5+
"main": "index.cjs",
6+
"type": "module",
67
"scripts": {
7-
"start": "node index.js"
8+
"start": "node index.cjs",
9+
"postinstall": "node index.cjs install"
810
},
911
"bin": {
10-
"simplelocalize": "./index.js"
12+
"install": "index.cjs"
1113
},
1214
"dependencies": {
1315
"axios": "^1.8.3"

0 commit comments

Comments
 (0)