Skip to content

Commit

Permalink
refactor: use std-env for stackblitz detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 14, 2023
1 parent 4d43b30 commit 933c0c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions src/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 (
Expand All @@ -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
Expand Down

0 comments on commit 933c0c3

Please sign in to comment.