+23
-0
@@ -22,1 +22,24 @@ /** | ||
| export function wslDrivesMountPoint(): Promise<string>; | ||
| /** | ||
| Convert a WSL Linux path to a Windows-accessible path. | ||
| URLs (strings starting with a protocol like `https://`) are returned unchanged. | ||
| @param path - The WSL path to convert (e.g., `/home/user/file.html`). | ||
| @returns The Windows-accessible path (e.g., `\\wsl.localhost\Ubuntu\home\user\file.html`) or the original path if conversion fails. | ||
| @example | ||
| ``` | ||
| import {convertWslPathToWindows} from 'wsl-utils'; | ||
| // Convert a Linux path | ||
| const windowsPath = await convertWslPathToWindows('/home/user/file.html'); | ||
| //=> '\\wsl.localhost\Ubuntu\home\user\file.html' | ||
| // URLs are not converted | ||
| const url = await convertWslPathToWindows('https://example.com'); | ||
| //=> 'https://example.com' | ||
| ``` | ||
| */ | ||
| export function convertWslPathToWindows(path: string): Promise<string>; |
+19
-0
| import process from 'node:process'; | ||
| import {promisify} from 'node:util'; | ||
| import childProcess from 'node:child_process'; | ||
| import fs, {constants as fsConstants} from 'node:fs/promises'; | ||
| import isWsl from 'is-wsl'; | ||
| const execFile = promisify(childProcess.execFile); | ||
| export const wslDrivesMountPoint = (() => { | ||
@@ -57,2 +61,17 @@ // Default value for "root" param | ||
| export const convertWslPathToWindows = async path => { | ||
| // Don't convert URLs | ||
| if (/^[a-z]+:\/\//i.test(path)) { | ||
| return path; | ||
| } | ||
| try { | ||
| const {stdout} = await execFile('wslpath', ['-aw', path], {encoding: 'utf8'}); | ||
| return stdout.trim(); | ||
| } catch { | ||
| // If wslpath fails, return the original path | ||
| return path; | ||
| } | ||
| }; | ||
| export {default as isWsl} from 'is-wsl'; |
+1
-1
| { | ||
| "name": "wsl-utils", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "Utilities for working with Windows Subsystem for Linux (WSL)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+26
-0
@@ -51,1 +51,27 @@ # wsl-utils | ||
| Get the mount point for fixed drives in WSL. | ||
| ### convertWslPathToWindows(path) | ||
| Returns: `Promise<string>` | ||
| Convert a WSL Linux path to a Windows-accessible path. | ||
| URLs (strings starting with a protocol like `https://`) are returned unchanged. | ||
| ```js | ||
| import {convertWslPathToWindows} from 'wsl-utils'; | ||
| // Convert a Linux path | ||
| const windowsPath = await convertWslPathToWindows('/home/user/file.html'); | ||
| //=> '\\wsl.localhost\Ubuntu\home\user\file.html' | ||
| // URLs are not converted | ||
| const url = await convertWslPathToWindows('https://example.com'); | ||
| //=> 'https://example.com' | ||
| ``` | ||
| #### path | ||
| Type: `string` | ||
| The WSL path to convert (e.g., `/home/user/file.html`). |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
6871
36.44%93
55%77
50.98%4
33.33%