@endevr-io/wsl-path

1.0.3 • Public • Published

@endever-io/wsl-path

GitHub release (latest SemVer) GitHub top language npm bundle size (scoped) GitHub Sponsors GitHub

wsl-path is a node package that converts converts Windows paths to WSL and vice-versa using just the path module. Other tools or packages require CLI tools to be installed on the WSL instance and use a newly spawned shell or cache to get the value.

Installation

You can use npm or yarn to install this package into your project

npm install @endevr-io/wsl-path

yarn add @endevr-io/wsl-path

Functions

windowsToWsl(absolutePath)string

Converts a Windows path to a WSL path

wslToWindows(absolutePath)string

Converts a WSL path to a Windows path

windowsToWsl(absolutePath) ⇒ string

Converts a Windows path to a WSL path

Kind: global function
Returns: string - normalized WSL path
Throws:

  • TypeError throws if absolutePath is not a string
  • Error throws if the path in not an absolute path
Param Type Description
absolutePath string an absolute Windows path

Example

const { windowsToWsl } = require('@endevr-io/wsl-path')
const wsl = windowsToWsl('C:\\Users\\endevr\\Documents')
console.log(wsl)
// '/mnt/c/Users/endevr/Documents'

wslToWindows(absolutePath) ⇒ string

Converts a WSL path to a Windows path

Kind: global function
Returns: string - normalized Windows path
Throws:

  • TypeError throws if absolutePath is not a string
  • Error throws if the path in not an absolute path
Param Type Description
absolutePath string an absolute WSL path

Example

const windows = wslToWindows('/mnt/c/Users/endevr/Documents')
console.log(windows)
// 'C:\\Users\\endevr\\Documents'

Contributing

Pull requests are welcome for bug fixes or feature requests. Make sure that all tests pass with npm run test before creating a pull request.

Sponsors

Support this project and possibly other open-source projects by becoming a sponsor. Higher tier sponsor will appear here with a logo and link to your website. Become a sponsor

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @endevr-io/wsl-path

Weekly Downloads

34

Version

1.0.3

License

MIT

Unpacked Size

8.36 kB

Total Files

5

Last publish

Collaborators

  • skulls