pax_global_header00006660000000000000000000000064136534725210014522gustar00rootroot0000000000000052 comment=7f3df4886d5f0292bda51cf240218ea643136961 is-wsl-2.2.0/000077500000000000000000000000001365347252100127415ustar00rootroot00000000000000is-wsl-2.2.0/.editorconfig000066400000000000000000000002571365347252100154220ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 is-wsl-2.2.0/.gitattributes000066400000000000000000000000231365347252100156270ustar00rootroot00000000000000* text=auto eol=lf is-wsl-2.2.0/.github/000077500000000000000000000000001365347252100143015ustar00rootroot00000000000000is-wsl-2.2.0/.github/funding.yml000066400000000000000000000001601365347252100164530ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/is-wsl custom: https://sindresorhus.com/donate is-wsl-2.2.0/.github/security.md000066400000000000000000000002631365347252100164730ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. is-wsl-2.2.0/.gitignore000066400000000000000000000000271365347252100147300ustar00rootroot00000000000000node_modules yarn.lock is-wsl-2.2.0/.npmrc000066400000000000000000000000231365347252100140540ustar00rootroot00000000000000package-lock=false is-wsl-2.2.0/.travis.yml000066400000000000000000000000651365347252100150530ustar00rootroot00000000000000language: node_js node_js: - '12' - '10' - '8' is-wsl-2.2.0/index.d.ts000066400000000000000000000005061365347252100146430ustar00rootroot00000000000000/** Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows). @example ``` import isWsl = require('is-wsl'); // When running inside Windows Subsystem for Linux console.log(isWsl); //=> true ``` */ declare const isWsl: boolean; export = isWsl; is-wsl-2.2.0/index.js000066400000000000000000000010561365347252100144100ustar00rootroot00000000000000'use strict'; const os = require('os'); const fs = require('fs'); const isDocker = require('is-docker'); const isWsl = () => { if (process.platform !== 'linux') { return false; } if (os.release().toLowerCase().includes('microsoft')) { if (isDocker()) { return false; } return true; } try { return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ? !isDocker() : false; } catch (_) { return false; } }; if (process.env.__IS_WSL_TEST__) { module.exports = isWsl; } else { module.exports = isWsl(); } is-wsl-2.2.0/index.test-d.ts000066400000000000000000000001321365347252100156130ustar00rootroot00000000000000import {expectType} from 'tsd'; import isWsl = require('.'); expectType(isWsl); is-wsl-2.2.0/license000066400000000000000000000021251365347252100143060ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-wsl-2.2.0/package.json000066400000000000000000000014011365347252100152230ustar00rootroot00000000000000{ "name": "is-wsl", "version": "2.2.0", "description": "Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)", "license": "MIT", "repository": "sindresorhus/is-wsl", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "check", "wsl", "windows", "subsystem", "linux", "detect", "bash", "process", "console", "terminal", "is" ], "dependencies": { "is-docker": "^2.0.0" }, "devDependencies": { "ava": "^1.4.1", "clear-module": "^3.2.0", "proxyquire": "^2.1.0", "tsd": "^0.7.2", "xo": "^0.24.0" } } is-wsl-2.2.0/readme.md000066400000000000000000000017431365347252100145250ustar00rootroot00000000000000# is-wsl [![Build Status](https://travis-ci.org/sindresorhus/is-wsl.svg?branch=master)](https://travis-ci.org/sindresorhus/is-wsl) > Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows) Can be useful if you need to work around unimplemented or buggy features in WSL. Supports both WSL 1 and WSL 2. ## Install ``` $ npm install is-wsl ``` ## Usage ```js const isWsl = require('is-wsl'); // When running inside Windows Subsystem for Linux console.log(isWsl); //=> true ``` ---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
is-wsl-2.2.0/test.js000066400000000000000000000051221365347252100142560ustar00rootroot00000000000000import test from 'ava'; import proxyquire from 'proxyquire'; import clearModule from 'clear-module'; test.beforeEach(() => { clearModule('.'); }); test('inside WSL 1', t => { process.env.__IS_WSL_TEST__ = true; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'linux'}); const isWsl = proxyquire('.', { fs: { readFileSync: () => 'Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014' } }); t.true(isWsl()); delete process.env.__IS_WSL_TEST__; Object.defineProperty(process, 'platform', {value: originalPlatform}); }); test('inside WSL 2', t => { process.env.__IS_WSL_TEST__ = true; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'linux'}); const isWsl = proxyquire('.', { fs: { readFileSync: () => 'Linux version 4.19.43-microsoft-standard (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 20 19:35:22 UTC 2019' } }); t.true(isWsl()); delete process.env.__IS_WSL_TEST__; Object.defineProperty(process, 'platform', {value: originalPlatform}); }); test('not inside WSL', t => { process.env.__IS_WSL_TEST__ = true; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'darwin'}); const isWsl = require('.'); t.false(isWsl()); delete process.env.__IS_WSL_TEST__; Object.defineProperty(process, 'platform', {value: originalPlatform}); }); test('not inside WSL, but inside Linux', t => { process.env.__IS_WSL_TEST__ = true; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'linux'}); const isWsl = proxyquire('.', { fs: { readFileSync: () => 'Linux version 4.19.43-standard (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 20 19:35:22 UTC 2019' }, os: { release: () => '' } }); t.false(isWsl()); delete process.env.__IS_WSL_TEST__; Object.defineProperty(process, 'platform', {value: originalPlatform}); }); test('inside WSL, but inside docker', t => { process.env.__IS_WSL_TEST__ = true; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'linux'}); const isWsl = proxyquire('.', { fs: { readFileSync: () => 'Linux version 4.19.43-microsoft-standard (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 20 19:35:22 UTC 2019' }, 'is-docker': () => true, os: { release: () => 'microsoft' } }); t.false(isWsl()); delete process.env.__IS_WSL_TEST__; Object.defineProperty(process, 'platform', {value: originalPlatform}); });