Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit f9430b8

Browse files
committed
add detecting platform
1 parent 1766648 commit f9430b8

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

npm/getBinary.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
const Binary = require('./binary');
2+
3+
const os = require('os');
4+
5+
function getPlatform() {
6+
const type = os.type();
7+
const arch = os.arch();
8+
9+
if (type === 'Windows_NT' && arch === 'x64') return 'win';
10+
if (type === 'Linux' && arch === 'x64') return 'linux';
11+
if (type === 'Darwin' && arch === 'x64') return 'macos';
12+
13+
throw new Error(`Unsupported platform: ${type} ${arch}`);
14+
}
15+
216
function getBinary() {
317
const name = 'rune';
418
const version = require('../package.json').version;
5-
const url = `https://github.com/ancientproject/cli/releases/download/v${version}/${name}-cli-win-64.zip`;
19+
const url = `https://github.com/ancientproject/cli/releases/download/v${version}/${name}-cli-${getPlatform()}-64.zip`;
620
return new Binary(url, { name });
721
}
822

npm/run.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
const getBinary = require('./getBinary');
44

5-
65
if(!getBinary().exist())
6+
{
7+
console.log(">> installing binaries...");
78
getBinary().install();
8-
getBinary().run();
9+
}
10+
else
11+
getBinary().run();

0 commit comments

Comments
 (0)