Buckets:
| import process from 'node:process'; | |
| import fs, {constants as fsConstants} from 'node:fs/promises'; | |
| import isWsl from 'is-wsl'; | |
| export const wslDrivesMountPoint = (() => { | |
| // Default value for "root" param | |
| // according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config | |
| const defaultMountPoint = '/mnt/'; | |
| let mountPoint; | |
| return async function () { | |
| if (mountPoint) { | |
| // Return memoized mount point value | |
| return mountPoint; | |
| } | |
| const configFilePath = '/etc/wsl.conf'; | |
| let isConfigFileExists = false; | |
| try { | |
| await fs.access(configFilePath, fsConstants.F_OK); | |
| isConfigFileExists = true; | |
| } catch {} | |
| if (!isConfigFileExists) { | |
| return defaultMountPoint; | |
| } | |
| const configContent = await fs.readFile(configFilePath, {encoding: 'utf8'}); | |
| const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent); | |
| if (!configMountPoint) { | |
| return defaultMountPoint; | |
| } | |
| mountPoint = configMountPoint.groups.mountPoint.trim(); | |
| mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`; | |
| return mountPoint; | |
| }; | |
| })(); | |
| export const powerShellPathFromWsl = async () => { | |
| const mountPoint = await wslDrivesMountPoint(); | |
| return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`; | |
| }; | |
| export const powerShellPath = async () => { | |
| if (isWsl) { | |
| return powerShellPathFromWsl(); | |
| } | |
| return `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`; | |
| }; | |
| export {default as isWsl} from 'is-wsl'; | |
Xet Storage Details
- Size:
- 1.55 kB
- Xet hash:
- 458e13616fa53efb5b91182e9e47cc9df72b95eccaf021ff8cd31023ee8295d8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.