Criada a API do site
This commit is contained in:
21
node_modules/wsl-utils/index.d.ts
generated
vendored
Normal file
21
node_modules/wsl-utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
Check if the current environment is Windows Subsystem for Linux (WSL).
|
||||
*/
|
||||
export const isWsl: boolean;
|
||||
|
||||
/**
|
||||
Get the PowerShell executable path in WSL environment.
|
||||
*/
|
||||
export function powerShellPathFromWsl(): Promise<string>;
|
||||
|
||||
/**
|
||||
Get the PowerShell executable path for the current environment.
|
||||
|
||||
Returns WSL path if in WSL, otherwise returns Windows path.
|
||||
*/
|
||||
export function powerShellPath(): Promise<string>;
|
||||
|
||||
/**
|
||||
Get the mount point for fixed drives in WSL.
|
||||
*/
|
||||
export function wslDrivesMountPoint(): Promise<string>;
|
||||
57
node_modules/wsl-utils/index.js
generated
vendored
Normal file
57
node_modules/wsl-utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import process from 'node:process';
|
||||
import fs, {constants as fsConstants} from 'node:fs/promises';
|
||||
import isWsl from 'is-wsl';
|
||||
|
||||
export const wslDrivesMountPoint = (() => {
|
||||
// Default value for "root" param
|
||||
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
|
||||
const defaultMountPoint = '/mnt/';
|
||||
|
||||
let mountPoint;
|
||||
|
||||
return async function () {
|
||||
if (mountPoint) {
|
||||
// Return memoized mount point value
|
||||
return mountPoint;
|
||||
}
|
||||
|
||||
const configFilePath = '/etc/wsl.conf';
|
||||
|
||||
let isConfigFileExists = false;
|
||||
try {
|
||||
await fs.access(configFilePath, fsConstants.F_OK);
|
||||
isConfigFileExists = true;
|
||||
} catch {}
|
||||
|
||||
if (!isConfigFileExists) {
|
||||
return defaultMountPoint;
|
||||
}
|
||||
|
||||
const configContent = await fs.readFile(configFilePath, {encoding: 'utf8'});
|
||||
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
||||
|
||||
if (!configMountPoint) {
|
||||
return defaultMountPoint;
|
||||
}
|
||||
|
||||
mountPoint = configMountPoint.groups.mountPoint.trim();
|
||||
mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;
|
||||
|
||||
return mountPoint;
|
||||
};
|
||||
})();
|
||||
|
||||
export const powerShellPathFromWsl = async () => {
|
||||
const mountPoint = await wslDrivesMountPoint();
|
||||
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
||||
};
|
||||
|
||||
export const powerShellPath = async () => {
|
||||
if (isWsl) {
|
||||
return powerShellPathFromWsl();
|
||||
}
|
||||
|
||||
return `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
||||
};
|
||||
|
||||
export {default as isWsl} from 'is-wsl';
|
||||
9
node_modules/wsl-utils/license
generated
vendored
Normal file
9
node_modules/wsl-utils/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.
|
||||
46
node_modules/wsl-utils/package.json
generated
vendored
Normal file
46
node_modules/wsl-utils/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "wsl-utils",
|
||||
"version": "0.1.0",
|
||||
"description": "Utilities for working with Windows Subsystem for Linux (WSL)",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/wsl-utils",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsc index.d.ts --skipLibCheck"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"wsl",
|
||||
"windows",
|
||||
"subsystem",
|
||||
"linux",
|
||||
"powershell",
|
||||
"mount",
|
||||
"utilities"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-wsl": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^6.3.0",
|
||||
"typescript": "^5.8.3",
|
||||
"xo": "^1.0.0"
|
||||
}
|
||||
}
|
||||
50
node_modules/wsl-utils/readme.md
generated
vendored
Normal file
50
node_modules/wsl-utils/readme.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# wsl-utils
|
||||
|
||||
> Utilities for working with [Windows Subsystem for Linux (WSL)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install wsl-utils
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {isWsl, powerShellPathFromWsl} from 'wsl-utils';
|
||||
|
||||
// Check if running in WSL
|
||||
console.log('Is WSL:', isWsl);
|
||||
|
||||
// Get PowerShell path from WSL
|
||||
console.log('PowerShell path:', await powerShellPathFromWsl());
|
||||
//=> '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### isWsl
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Check if the current environment is Windows Subsystem for Linux (WSL).
|
||||
|
||||
### powerShellPathFromWsl()
|
||||
|
||||
Returns: `Promise<string>`
|
||||
|
||||
Get the PowerShell executable path in WSL environment.
|
||||
|
||||
### powerShellPath()
|
||||
|
||||
Returns: `Promise<string>`
|
||||
|
||||
Get the PowerShell executable path for the current environment.
|
||||
|
||||
Returns WSL path if in WSL, otherwise returns Windows path.
|
||||
|
||||
### wslDrivesMountPoint()
|
||||
|
||||
Returns: `Promise<string>`
|
||||
|
||||
Get the mount point for fixed drives in WSL.
|
||||
Reference in New Issue
Block a user