File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { execaCommandSync } from "execa"
2
2
3
+ type Options = {
4
+ arch : string
5
+ }
6
+
7
+ function toString ( value : string | undefined ) : string | undefined {
8
+ switch ( value ) {
9
+ case undefined :
10
+ case "" :
11
+ return undefined
12
+ default :
13
+ return value
14
+ }
15
+ }
16
+
17
+ function parserOptions ( ) : Options {
18
+ return {
19
+ arch : toString ( process . env . npm_config_arch ) ?? process . arch ,
20
+ }
21
+ }
22
+
3
23
async function main ( ) {
4
- console . log ( "Building distribution binary..." )
24
+ const opts = parserOptions ( )
25
+
26
+ console . log ( "Building distribution binary with options " , opts )
5
27
6
- const prebuildArch = getNodearch ( )
28
+ const prebuildArch = getNodearch ( opts )
7
29
30
+ // TODO test the triple feature
8
31
if ( typeof process . env . TRIPLE === "string" ) {
9
32
const TRIPLE = process . env . TRIPLE
10
33
@@ -45,18 +68,16 @@ main().catch(e => {
45
68
throw e
46
69
} )
47
70
48
- function getNodearch ( ) : string {
49
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
50
- const arch = process . env . ARCH || process . arch
51
- switch ( arch ) {
71
+ function getNodearch ( opts : Options ) : string {
72
+ switch ( opts . arch ) {
52
73
case "x86" : {
53
74
return "ia32"
54
75
}
55
76
case "x86_64" : {
56
77
return "x64"
57
78
}
58
79
default : {
59
- return arch
80
+ return opts . arch
60
81
}
61
82
}
62
83
}
You can’t perform that action at this time.
0 commit comments