Git Product home page Git Product logo

node-wsl's Introduction

node-wsl

build status code coverage code style styled with prettier license npm downloads

A wrapper for the Windows Subsystem for Linux (WSL) cli

Install

wsl:

You'll need Windows with WSL 2 to use this library. node-wsl uses wsl.exe under the hood.

npm:

npm install node-wsl

yarn:

yarn add node-wsl

Usage

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,
});

API

⚠️ execa does not use a shell by default. So features like variable substitution will not work without specifying a shell

⚠️ if Microsoft changes the wsl.exe interface with a future update, this package will probly break!

complete api docs can be found at: https://grmlin.github.io/node-wsl


Contributors

Name Website
Andreas Wehr https://github.com/grmlin

FAQ

  • 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.

Windows Compatibility

node-wsl was tested with the following versions of Windows

Version Build tested
2004 19041.450

License

MIT © Andreas Wehr

[]: https://grmlin.github.io/node-wsl

node-wsl's People

Contributors

grmlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-wsl's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.