-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlink-binary.js
35 lines (30 loc) · 1.14 KB
/
link-binary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
// only supports macos and linux
// assumption is the package.json's os property is limiting the package to these oses
// i am sure if this is installed on some other os fire will rain from the sky
const path = require('path');
const fs = require('fs');
const debug = require('debug')('jqcw');
const BinWrapper = require('bin-wrapper');
const base = 'https://github.com/stedolan/jq/releases/download/jq-1.6';
const platform = process.platform === 'darwin' ? 'osx' : 'linux';
const arch = process.platform === 'darwin' ? '-amd64' : process.arch.replace(/^x/, '');
const jqExecutableName = `jq-${platform}${arch}`;
const bin = new BinWrapper()
.src(`${base}/jq-osx-amd64`, 'darwin')
.src(`${base}/jq-linux64`, 'linux', 'x64')
.src(`${base}/jq-linux32`, 'linux', 'x32')
.dest(path.join('vendor'))
.use(jqExecutableName)
.version('>=1.6');
debug(JSON.stringify({base, platform, arch, jqExecutableName}));
bin.run(['--version'], err => {
if (err) {
debug(`Error from bin.run: ${err}`);
}
fs.symlink(jqExecutableName, path.join('vendor', 'jq'), err => {
if (err) {
debug(`Error creating symlink: ${err}`);
}
});
});