From 933c0c39530a499075cd436270eb15ced74303d0 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 14 Sep 2023 21:24:15 +0200 Subject: [PATCH] refactor: use `std-env` for stackblitz detection --- package.json | 1 + pnpm-lock.yaml | 4 +++- src/_utils.ts | 13 ++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8ed61b5..dcfbff0 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "mlly": "^1.4.2", "node-forge": "^1.3.1", "pathe": "^1.1.1", + "std-env": "^3.4.3", "ufo": "^1.3.0", "untun": "^0.1.2", "uqr": "^0.1.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4480a3..e3732f5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: pathe: specifier: ^1.1.1 version: 1.1.1 + std-env: + specifier: ^3.4.3 + version: 3.4.3 ufo: specifier: ^1.3.0 version: 1.3.0 @@ -3931,7 +3934,6 @@ packages: /std-env@3.4.3: resolution: {integrity: sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==} - dev: true /string.prototype.trim@1.2.8: resolution: {integrity: sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==} diff --git a/src/_utils.ts b/src/_utils.ts index c72afb1..a73d38c 100644 --- a/src/_utils.ts +++ b/src/_utils.ts @@ -2,6 +2,7 @@ import { networkInterfaces } from "node:os"; import { relative } from "pathe"; import { colors } from "consola/utils"; import { consola } from "consola"; +import { provider } from "std-env"; import { ListenOptions } from "./types"; import { isWsl } from "./lib/wsl"; import { isDocker } from "./lib/docker"; @@ -91,9 +92,11 @@ export function getPublicURL( return listhenOptions.publicURL; } - const stackblitzURL = detectStackblitzURL(listhenOptions._entry); - if (stackblitzURL) { - return stackblitzURL; + if (provider === "stackblitz") { + const stackblitzURL = detectStackblitzURL(listhenOptions._entry); + if (stackblitzURL) { + return stackblitzURL; + } } if ( @@ -107,10 +110,6 @@ export function getPublicURL( function detectStackblitzURL(entry?: string) { try { - if (process.env.SHELL !== "/bin/jsh") { - return; - } - const cwd = process.env.PWD || ("" as string); // Editor