File tree 5 files changed +13
-24
lines changed
5 files changed +13
-24
lines changed Original file line number Diff line number Diff line change
1
+ /package-lock.json
2
+ /node_modules /
Original file line number Diff line number Diff line change 1
- const { Binary } = require ( 'binary-install' ) ;
2
- const os = require ( 'os' ) ;
1
+ import { Binary } from 'simple-binary-install' ;
2
+ import * as os from 'os' ;
3
+ import * as fs from 'fs' ;
3
4
4
5
function getPlatform ( ) {
5
6
const type = os . type ( ) ;
@@ -28,13 +29,11 @@ function getPlatform() {
28
29
throw new Error ( `Unsupported platform: ${ type } ${ arch } . Please create an issue at https://github.com/coralogix/protofetch/issues` ) ;
29
30
}
30
31
31
- function getBinary ( ) {
32
+ export function getBinary ( ) {
32
33
const platform = getPlatform ( ) ;
33
- const version = require ( './package.json' ) . version ;
34
+ const { version } = JSON . parse ( fs . readFileSync ( './package.json' ) ) ;
34
35
const url = `https://github.com/coralogix/protofetch/releases/download/v${ version } /protofetch_${ platform } .tar.gz` ;
35
36
const name = 'protofetch' ;
36
37
37
38
return new Binary ( name , url )
38
39
}
39
-
40
- module . exports = getBinary ;
Original file line number Diff line number Diff line change 5
5
"repository" : " https://github.com/coralogix/protofetch.git" ,
6
6
"homepage" : " https://github.com/coralogix/protofetch" ,
7
7
"license" : " Apache-2.0" ,
8
+ "type" : " module" ,
8
9
"bin" : {
9
10
"protofetch" : " run.js"
10
11
},
11
12
"scripts" : {
12
13
"postinstall" : " node scripts.js install"
13
14
},
14
15
"dependencies" : {
15
- "binary-install" : " ^1.0.1"
16
- },
17
- "devDependencies" : {
18
- "ncp" : " ^2.0.0" ,
19
- "vuepress" : " ^1.9.7"
16
+ "simple-binary-install" : " ^0.2.1"
20
17
},
21
18
"keywords" : [
22
19
" proto" ,
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
- const getBinary = require ( './getBinary' ) ;
2
+ import { getBinary } from './getBinary.js' ;
3
3
4
- const binary = getBinary ( ) ;
5
- binary . run ( ) ;
4
+ getBinary ( ) . run ( ) ;
Original file line number Diff line number Diff line change 1
- function getBinary ( { fatal } ) {
2
- try {
3
- return require ( './getBinary' ) ( ) ;
4
- } catch ( err ) {
5
- if ( fatal ) throw err ;
6
- }
7
- }
1
+ import { getBinary } from './getBinary.js' ;
8
2
9
3
if ( process . argv . includes ( 'install' ) ) {
10
- const binary = getBinary ( { fatal : true } ) ;
11
- if ( binary ) binary . install ( ) ;
4
+ getBinary ( ) . install ( ) ;
12
5
}
13
-
You can’t perform that action at this time.
0 commit comments