Skip to content

Commit

Permalink
Replace binary-install with simple-binary-install (#133)
Browse files Browse the repository at this point in the history
`binary-install` has open CVEs, and `simple-binary-install` seems to do
the same thing, but with fewer dependencies.
  • Loading branch information
rtimush authored Apr 22, 2024
1 parent 58711be commit a335efb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/package-lock.json
/node_modules/
11 changes: 5 additions & 6 deletions .github/npm/getBinary.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Binary } = require('binary-install');
const os = require('os');
import { Binary } from 'simple-binary-install';
import * as os from 'os';
import * as fs from 'fs';

function getPlatform() {
const type = os.type();
Expand Down Expand Up @@ -28,13 +29,11 @@ function getPlatform() {
throw new Error(`Unsupported platform: ${type} ${arch}. Please create an issue at https://github.com/coralogix/protofetch/issues`);
}

function getBinary() {
export function getBinary() {
const platform = getPlatform();
const version = require('./package.json').version;
const { version } = JSON.parse(fs.readFileSync('./package.json'));
const url = `https://github.com/coralogix/protofetch/releases/download/v${version}/protofetch_${platform}.tar.gz`;
const name = 'protofetch';

return new Binary(name, url)
}

module.exports = getBinary;
7 changes: 2 additions & 5 deletions .github/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
"repository": "https://github.com/coralogix/protofetch.git",
"homepage": "https://github.com/coralogix/protofetch",
"license": "Apache-2.0",
"type": "module",
"bin": {
"protofetch": "run.js"
},
"scripts": {
"postinstall": "node scripts.js install"
},
"dependencies": {
"binary-install": "^1.0.1"
},
"devDependencies": {
"ncp": "^2.0.0",
"vuepress": "^1.9.7"
"simple-binary-install": "^0.2.1"
},
"keywords": [
"proto",
Expand Down
5 changes: 2 additions & 3 deletions .github/npm/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
const getBinary = require('./getBinary');
import { getBinary } from './getBinary.js';

const binary = getBinary();
binary.run();
getBinary().run();
12 changes: 2 additions & 10 deletions .github/npm/scripts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
function getBinary({ fatal }) {
try {
return require('./getBinary')();
} catch (err) {
if (fatal) throw err;
}
}
import { getBinary } from './getBinary.js';

if (process.argv.includes('install')) {
const binary = getBinary({ fatal: true });
if (binary) binary.install();
getBinary().install();
}

0 comments on commit a335efb

Please sign in to comment.