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

Commit

Permalink
add detecting platform
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Apr 26, 2020
1 parent 1766648 commit f9430b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 15 additions & 1 deletion npm/getBinary.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
const Binary = require('./binary');

const os = require('os');

function getPlatform() {
const type = os.type();
const arch = os.arch();

if (type === 'Windows_NT' && arch === 'x64') return 'win';
if (type === 'Linux' && arch === 'x64') return 'linux';
if (type === 'Darwin' && arch === 'x64') return 'macos';

throw new Error(`Unsupported platform: ${type} ${arch}`);
}

function getBinary() {
const name = 'rune';
const version = require('../package.json').version;
const url = `https://github.com/ancientproject/cli/releases/download/v${version}/${name}-cli-win-64.zip`;
const url = `https://github.com/ancientproject/cli/releases/download/v${version}/${name}-cli-${getPlatform()}-64.zip`;
return new Binary(url, { name });
}

Expand Down
7 changes: 5 additions & 2 deletions npm/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

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


if(!getBinary().exist())
{
console.log(">> installing binaries...");
getBinary().install();
getBinary().run();
}
else
getBinary().run();

0 comments on commit f9430b8

Please sign in to comment.