Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

wsl-utils

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wsl-utils - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+23
-0
index.d.ts

@@ -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>;
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",

@@ -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`).