Skip to content

Commit 7e8f72d

Browse files
refactor: address comments.
1 parent 3c6423b commit 7e8f72d

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
"build:esm": "KNIGHTED_PRIMARY_CDN=esm npm run build",
3333
"build:jspm": "KNIGHTED_PRIMARY_CDN=jspmGa npm run build",
3434
"build:importmap-mode": "KNIGHTED_PRIMARY_CDN=importMap npm run build",
35-
"preview": "KNIGHTED_PRIMARY_CDN=esm npm run build && http-server dist -a localhost -p 8081 -c-1 -o index.html",
35+
"preview": "npm run build && http-server dist -a localhost -p 8081 -c-1 -o index.html",
3636
"check-types": "tsc -p tsconfig.json",
3737
"lint:playwright": "eslint playwright playwright.config.ts",
38-
"test:e2e": "KNIGHTED_PRIMARY_CDN=esm npm run build && PLAYWRIGHT_WEB_SERVER_MODE=preview PLAYWRIGHT_PORT=8081 playwright test",
38+
"test:e2e": "npm run build && PLAYWRIGHT_WEB_SERVER_MODE=preview PLAYWRIGHT_PORT=8081 playwright test",
3939
"test:e2e:dev": "playwright test",
40-
"test:e2e:headed": "KNIGHTED_PRIMARY_CDN=esm npm run build && PLAYWRIGHT_WEB_SERVER_MODE=preview PLAYWRIGHT_PORT=8081 playwright test --headed",
40+
"test:e2e:headed": "npm run build && PLAYWRIGHT_WEB_SERVER_MODE=preview PLAYWRIGHT_PORT=8081 playwright test --headed",
4141
"test": "echo \"Error: no test specified\" && exit 1",
4242
"prettier": "prettier --write .",
4343
"lint": "oxlint src scripts && npm run lint:playwright"

scripts/build-js.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,19 @@ const collectJavaScriptFiles = async directory => {
3030

3131
return nested.flat()
3232
}
33-
const distStats = await stat(distDir)
33+
let distStats
34+
35+
try {
36+
distStats = await stat(distDir)
37+
} catch (error) {
38+
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
39+
throw new Error('dist directory is missing. Run build:prepare first.', {
40+
cause: error,
41+
})
42+
}
43+
44+
throw error
45+
}
3446

3547
if (!distStats.isDirectory()) {
3648
throw new Error('dist directory is missing. Run build:prepare first.')

scripts/build.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const run = script => {
1111
env,
1212
})
1313

14+
if (result.error) {
15+
throw new Error(`Failed to run npm script "${script}".`, {
16+
cause: result.error,
17+
})
18+
}
19+
1420
if (result.status !== 0) {
1521
process.exit(result.status ?? 1)
1622
}

0 commit comments

Comments
 (0)