File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -377,10 +377,16 @@ export const getMediaMime = (filePath?: string): string => {
377
377
return ( filePath && mimeTypes [ path . extname ( filePath ) ] ) || "text/plain"
378
378
}
379
379
380
- export const isWsl = async ( ) : Promise < boolean > => {
380
+ /**
381
+ * A helper function that checks if the platform is Windows Subsystem for Linux
382
+ * (WSL)
383
+ *
384
+ * @returns {Boolean } boolean if it is WSL
385
+ */
386
+ export const isWsl = async ( platform : NodeJS . Platform , procVersionFilePath : string ) : Promise < boolean > => {
381
387
return (
382
- ( process . platform === "linux" && os . release ( ) . toLowerCase ( ) . indexOf ( "microsoft" ) !== - 1 ) ||
383
- ( await fs . readFile ( "/proc/version" , "utf8" ) ) . toLowerCase ( ) . indexOf ( "microsoft" ) !== - 1
388
+ ( platform === "linux" && os . release ( ) . toLowerCase ( ) . indexOf ( "microsoft" ) !== - 1 ) ||
389
+ ( await fs . readFile ( procVersionFilePath , "utf8" ) ) . toLowerCase ( ) . indexOf ( "microsoft" ) !== - 1
384
390
)
385
391
}
386
392
@@ -398,7 +404,7 @@ export const open = async (address: URL | string): Promise<void> => {
398
404
}
399
405
const args = [ ] as string [ ]
400
406
const options = { } as cp . SpawnOptions
401
- const platform = ( await isWsl ( ) ) ? "wsl" : process . platform
407
+ const platform = ( await isWsl ( process . platform , "/proc/version" ) ) ? "wsl" : process . platform
402
408
let command = platform === "darwin" ? "open" : "xdg-open"
403
409
if ( platform === "win32" || platform === "wsl" ) {
404
410
command = platform === "wsl" ? "cmd.exe" : "cmd"
You can’t perform that action at this time.
0 commit comments