A wrapper for the Windows Subsystem for Linux (WSL) cli
npm install node-wsl





> A wrapper for the Windows Subsystem for Linux (WSL) cli
[wsl][]:
You'll need Windows with WSL 2 to use this library. node-wsl uses wsl.exe under the hood.
> ⚠️ if Microsoft changes the wsl.exe interface with a future update, this package will probly break!
[npm][]:
``sh`
npm install node-wsl
[yarn][]:
`sh`
yarn add node-wsl
`js
const { status } = require('node-wsl');
const status = await status();
assert.deepEqual(status, {
distributions: [
{
default: true,
running: true,
stopped: false,
name: 'Ubuntu',
state: 'Running',
version: '2',
},
{
default: false,
running: false,
stopped: true,
name: 'kali-linux',
state: 'Stopped',
version: '2',
},
{
default: false,
running: true,
stopped: false,
name: 'Debian',
state: 'Running',
version: '2',
},
],
runningDistributions: [
{
default: true,
running: true,
stopped: false,
name: 'Ubuntu',
state: 'Running',
version: '2',
},
{
default: false,
running: true,
stopped: false,
name: 'Debian',
state: 'Running',
version: '2',
},
],
stoppedDistributions: [
{
default: false,
running: false,
stopped: true,
name: 'kali-linux',
state: 'Stopped',
version: '2',
},
],
defaultDistribution: {
default: true,
running: true,
stopped: false,
name: 'Ubuntu',
state: 'Running',
version: '2',
},
total: 3,
running: 2,
stopped: 1,
});
`
----------------
> ⚠️ execa does not use a shell by default. So features like variable substitution will not work without specifying a shell
-------
| Name | Website |
| ---------------- | --------------------------- |
| Andreas Wehr |
* WSL fails because a path/file was not found
That probably if you some form of variable substitution in a path, eg. ~/backup.tar, without specifying a shell for execa. Check the execa documentation for a detailed explanation.
node-wsl` was tested with the following versions of Windows
| Version | Build | tested |
| ------- | --------- | ------------------ |
| 2004 | 19041.450 | :white_check_mark: |
##
[wsl]: https://docs.microsoft.com/windows/wsl/
[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/
[execa-documentation]: https://github.com/sindresorhus/execa/blob/master/readme.md#execafile-arguments-options "execa documentation"