From 4a0453a1b967729524c4cc9327caa0079a943e69 Mon Sep 17 00:00:00 2001 From: hugoalh <32359235+hugoalh@users.noreply.github.com> Date: Wed, 8 May 2024 17:32:23 +0800 Subject: [PATCH] Fix syntax --- env.ts | 5 ----- is_root.ts | 5 ++++- is_wsl.ts | 10 ++++++++-- npm/package.json | 1 + pathext.ts | 5 ++++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/env.ts b/env.ts index e7077b3..49f1b22 100644 --- a/env.ts +++ b/env.ts @@ -117,7 +117,6 @@ export default env; * > | Deno | Environment Variable (`allow-env`) | All | * @param {string} key Key of the environment variable. * @returns {void} - * @deprecated Replaced by method {@linkcode env.delete}. */ export function deleteEnv(key: string): void { return env.delete(key); @@ -131,7 +130,6 @@ export function deleteEnv(key: string): void { * > |:--|:--|:--| * > | Deno | Environment Variable (`allow-env`) | All | * @returns {{ [key: string]: string; }} A snapshot of the environment variables. - * @deprecated Replaced by method {@linkcode env.getAll}. */ export function getAllEnv(): { [key: string]: string; } { return env.getAll(); @@ -146,7 +144,6 @@ export function getAllEnv(): { [key: string]: string; } { * > | Deno | Environment Variable (`allow-env`) | All | * @param {string} key Key of the environment variable. * @returns {string | undefined} Value of the environment variable. - * @deprecated Replaced by method {@linkcode env.get}. */ export function getEnv(key: string): string | undefined { return env.get(key); @@ -161,7 +158,6 @@ export function getEnv(key: string): string | undefined { * > | Deno | Environment Variable (`allow-env`) | All | * @param {string} key Key of the environment variable. * @returns {boolean} Determine result. - * @deprecated Replaced by method {@linkcode env.has}. */ export function hasEnv(key: string): boolean { return env.has(key); @@ -177,7 +173,6 @@ export function hasEnv(key: string): boolean { * @param {string} key Key of the environment variable. * @param {string} value Value of the environment variable. * @returns {void} - * @deprecated Replaced by method {@linkcode env.set}. */ export function setEnv(key: string, value: string): void { return env.set(key, value); diff --git a/is_root.ts b/is_root.ts index 30cc1f2..dba8839 100644 --- a/is_root.ts +++ b/is_root.ts @@ -10,6 +10,9 @@ import process from "node:process"; * @returns {boolean} Determine result. */ export function isEnvironmentRoot(): boolean { - return (process.getuid?.() === 0); + return ( + (typeof Deno !== "undefined" && Deno.uid() === 0) || + process.getuid?.() === 0 + ); } export default isEnvironmentRoot; diff --git a/is_wsl.ts b/is_wsl.ts index 755a87d..287284d 100644 --- a/is_wsl.ts +++ b/is_wsl.ts @@ -13,7 +13,10 @@ const regexpWordMicrosoft = /microsoft/i; * @returns {Promise} Determine result. */ export async function isEnvironmentWSL(): Promise { - if (process.platform !== "linux") { + if ( + (typeof Deno !== "undefined" && Deno.build.os !== "linux") || + process.platform !== "linux" + ) { return false; } try { @@ -34,7 +37,10 @@ export default isEnvironmentWSL; * @returns {boolean} Determine result. */ export function isEnvironmentWSLSync(): boolean { - if (process.platform !== "linux") { + if ( + (typeof Deno !== "undefined" && Deno.build.os !== "linux") || + process.platform !== "linux" + ) { return false; } try { diff --git a/npm/package.json b/npm/package.json index 2555c1d..fb6135a 100644 --- a/npm/package.json +++ b/npm/package.json @@ -86,6 +86,7 @@ "scripts": { "build": "tsc" }, + "dependencies": { }, "devDependencies": { "typescript": "^5.4.5" }, diff --git a/pathext.ts b/pathext.ts index 1395ba3..bf43314 100644 --- a/pathext.ts +++ b/pathext.ts @@ -1,6 +1,9 @@ import process from "node:process"; import { envDelimitation } from "./_delimitation.ts"; -const isOSWindows: boolean = process.platform === "win32"; +const isOSWindows: boolean = ( + (typeof Deno !== "undefined" && Deno.build.os === "windows") || + process.platform === "win32" +); /** * Cross runtime environment variables `PATHEXT` interface. *