Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scripts/tasks/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import detectFreePort from 'detect-port';
import waitOn from 'wait-on';

import type { AllTemplatesKey } from '../../code/lib/cli-storybook/src/sandbox-templates';
Expand All @@ -21,7 +20,12 @@ export const dev: Task = {
dependsOn: ['sandbox'],
async ready({ key }) {
const port = getDevPort(key);
return (await detectFreePort(port)) !== port;
try {
await fetch(`http://localhost:${port}/iframe.html`, { signal: AbortSignal.timeout(1000) });
return true;
} catch {
return false;
}
},
async run({ sandboxDir, key, selectedTask }, { dryRun, debug }) {
const controller = new AbortController();
Expand Down
8 changes: 6 additions & 2 deletions scripts/tasks/serve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import detectFreePort from 'detect-port';
import waitOn from 'wait-on';

import type { AllTemplatesKey } from '../../code/lib/cli-storybook/src/sandbox-templates';
Expand All @@ -21,7 +20,12 @@ export const serve: Task = {
dependsOn: ['build'],
async ready({ key }) {
const port = getServePort(key);
return (await detectFreePort(port)) !== port;
try {
await fetch(`http://localhost:${port}/iframe.html`, { signal: AbortSignal.timeout(1000) });
return true;
} catch {
return false;
}
},
async run({ builtSandboxDir, key }, { debug, dryRun }) {
const port = getServePort(key);
Expand Down
Loading