File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,12 +170,18 @@ export const OsUtils = {
170170 } ,
171171
172172 async getLinuxDistro ( ) : Promise < LinuxDistro | undefined > {
173- const osRelease = await fs . readFile ( '/etc/os-release' , 'utf8' ) ;
174- const lines = osRelease . split ( '\n' ) ;
175- for ( const line of lines ) {
176- if ( line . startsWith ( 'ID=' ) ) {
177- const distroId = line . slice ( 3 ) . trim ( ) . replaceAll ( '"' , '' ) ;
178- return Object . values ( LinuxDistro ) . includes ( distroId as LinuxDistro ) ? distroId as LinuxDistro : undefined ;
173+ for ( const candidate of [ '/etc/os-release' , '/usr/lib/os-release' ] ) {
174+ let osRelease : string ;
175+ try {
176+ osRelease = await fs . readFile ( candidate , 'utf8' ) ;
177+ } catch {
178+ continue ;
179+ }
180+ for ( const line of osRelease . split ( '\n' ) ) {
181+ if ( line . startsWith ( 'ID=' ) ) {
182+ const distroId = line . slice ( 3 ) . trim ( ) . replaceAll ( '"' , '' ) ;
183+ return Object . values ( LinuxDistro ) . includes ( distroId as LinuxDistro ) ? distroId as LinuxDistro : undefined ;
184+ }
179185 }
180186 }
181187
Original file line number Diff line number Diff line change @@ -51,12 +51,18 @@ export const ShellUtils = {
5151 } ,
5252
5353 async getLinuxDistro ( ) : Promise < LinuxDistro | undefined > {
54- const osRelease = await fs . readFile ( '/etc/os-release' , 'utf8' ) ;
55- const lines = osRelease . split ( '\n' ) ;
56- for ( const line of lines ) {
57- if ( line . startsWith ( 'ID=' ) ) {
58- const distroId = line . slice ( 3 ) . trim ( ) . replaceAll ( '"' , '' ) ;
59- return Object . values ( LinuxDistro ) . includes ( distroId as LinuxDistro ) ? distroId as LinuxDistro : undefined ;
54+ for ( const candidate of [ '/etc/os-release' , '/usr/lib/os-release' ] ) {
55+ let osRelease : string ;
56+ try {
57+ osRelease = await fs . readFile ( candidate , 'utf8' ) ;
58+ } catch {
59+ continue ;
60+ }
61+ for ( const line of osRelease . split ( '\n' ) ) {
62+ if ( line . startsWith ( 'ID=' ) ) {
63+ const distroId = line . slice ( 3 ) . trim ( ) . replaceAll ( '"' , '' ) ;
64+ return Object . values ( LinuxDistro ) . includes ( distroId as LinuxDistro ) ? distroId as LinuxDistro : undefined ;
65+ }
6066 }
6167 }
6268
You can’t perform that action at this time.
0 commit comments