1
1
#!/usr/bin/env node
2
2
3
- import os from 'os' ;
4
-
5
3
import chalk from 'chalk' ;
6
4
7
5
import meow from 'meow' ;
@@ -14,6 +12,7 @@ import {
14
12
EDITOR_INSTALLERS_FILE_PATH ,
15
13
updateEditorInstallers ,
16
14
} from '../lib/update-editor-installers.js' ;
15
+ import { getOperatingSystemKey } from '../lib/os.js' ;
17
16
import { getUnityUrls } from '../lib/get-unity-urls.js' ;
18
17
import { parseVersionFromString } from '../lib/parsers.js' ;
19
18
@@ -64,12 +63,6 @@ const cli = meow(
64
63
}
65
64
) ;
66
65
67
- const osKeyMap = {
68
- Darwin : 'mac' ,
69
- Linux : 'linux' ,
70
- Windows_NT : 'win64' ,
71
- } ;
72
-
73
66
const DEFAULT_CACHE_TTL = 3600000 ;
74
67
75
68
updateNotifier ( { pkg : ( await readPackageUp ( ) ) . packageJson } ) . notify ( ) ;
@@ -84,10 +77,12 @@ if (cli.flags.file) {
84
77
}
85
78
}
86
79
80
+ const osKey = getOperatingSystemKey ( ) ;
81
+
87
82
if ( cli . flags . offline ) {
88
83
const urls = await getUnityUrls ( cli . input [ 0 ] , EDITOR_INSTALLERS_FILE_PATH ) ;
89
84
90
- process . stdout . write ( `${ urls [ osKeyMap [ os . type ( ) ] ] } ` ) ;
85
+ process . stdout . write ( `${ urls [ osKey ] } ` ) ;
91
86
} else {
92
87
try {
93
88
await updateEditorInstallers (
@@ -97,7 +92,7 @@ if (cli.flags.offline) {
97
92
98
93
const urls = await getUnityUrls ( cli . input [ 0 ] , EDITOR_INSTALLERS_FILE_PATH ) ;
99
94
100
- process . stdout . write ( `${ urls [ osKeyMap [ os . type ( ) ] ] } ` ) ;
95
+ process . stdout . write ( `${ urls [ osKey ] } ` ) ;
101
96
} catch ( error ) {
102
97
process . stderr . write ( `${ chalk . red ( 'Error:' ) } ${ error . message } ` ) ;
103
98
}
0 commit comments