From 128738ae656e80ea2c99d8a4a03327c5827db64e Mon Sep 17 00:00:00 2001 From: James Dabbs Date: Wed, 3 May 2023 07:51:29 -0600 Subject: [PATCH] feat: auto host mount dev server when running in a codespace also clarify some documentation to consistently expect `pnpm` as a package manager / task runner. `npm` _should_ work equivalently in most cases, but being consistent might help prevent unexpected surprises. --- README.md | 5 +---- packages/viewer/rollup.config.mjs | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fbc6d91c..a59c921f 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,7 @@ $ curl -s localhost:3141/refs/heads/master | jq '.version' ```bash # in packages/viewer # compile .js and .css assets -npm run build - -# serve assets and expose them externally -npm run start -- --host +pnpm run dev ``` ## Troubleshooting diff --git a/packages/viewer/rollup.config.mjs b/packages/viewer/rollup.config.mjs index df570b6a..49c032ec 100644 --- a/packages/viewer/rollup.config.mjs +++ b/packages/viewer/rollup.config.mjs @@ -13,6 +13,7 @@ import copy from 'rollup-plugin-copy'; import { spawn } from 'node:child_process'; const production = !process.env.ROLLUP_WATCH; +const codespace = process.env.CODESPACES === 'true'; function serve() { let server; @@ -24,7 +25,10 @@ function serve() { return { writeBundle() { if (server) return; - server = spawn('npm', ['run', 'start', '--', '--dev'], { + const args = ['run', 'start', '--', '--dev']; + if (codespace) { args.push('--host') } + + server = spawn('pnpm', args, { stdio: ['ignore', 'inherit', 'inherit'], shell: true });