@jonmilner/local-ci 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/vitest-entry.d.ts +2 -1
- package/dist/vitest-entry.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,9 +116,9 @@ await withCheckLock("my-repo browser", async () => {
|
|
|
116
116
|
import { withBrowserLock } from "@jonmilner/local-ci/vitest";
|
|
117
117
|
import { defineConfig } from "vitest/config";
|
|
118
118
|
|
|
119
|
-
export default defineConfig(
|
|
119
|
+
export default withBrowserLock(defineConfig({ test: { projects: [/* unit, storybook, ... */] } }));
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
`withBrowserLock(config)` appends the setup to the root `test.globalSetup`, which vitest runs once per run in its main process, before any worker or browser starts; `browserLockSetup` is the setup file's path, for configs that list `globalSetup` themselves. The setup looks at the projects the run selected (after `--project` filters): if any has `browser.enabled`, it takes the lock, waiting as long as it takes and printing `local-ci: waiting for the check lock, held by pid <pid> (<holder>)`, and its teardown releases it when the run ends, pass or fail. A run with only node or jsdom projects never takes it. The holder is `<name> vitest browser`, `<name>` from the nearest `package.json`. A run nested under a holder (`local-ci run -- pnpm test`, a `pnpm check` that local-ci runs) goes ahead without waiting. Projects that each list the setup share one lock, even through separate copies of the module, so a run takes it once. Ctrl-C, SIGTERM or SIGHUP releases it and ends the run; a run killed outright is taken over as a dead holder. Watch mode takes no lock, so a watcher left open never blocks the machine's checks; agents and scripts, with no TTY, get run mode. It needs vitest 3 or later, whose setup sees the run's projects.
|
|
122
|
+
Pass it the config `defineConfig` returns, as shown: its type rejects a `test` object literal with keys other than `globalSetup` (such as `projects`), so `withBrowserLock({ test: { projects } })` and `defineConfig(withBrowserLock({...}))` fail to typecheck, and it takes no function config (`defineConfig(() => ...)`). `withBrowserLock(config)` returns the config's own type and appends the setup to the root `test.globalSetup`, which vitest runs once per run in its main process, before any worker or browser starts; `browserLockSetup` is the setup file's path, for configs that list `globalSetup` themselves. The setup looks at the projects the run selected (after `--project` filters): if any has `browser.enabled`, it takes the lock, waiting as long as it takes and printing `local-ci: waiting for the check lock, held by pid <pid> (<holder>)`, and its teardown releases it when the run ends, pass or fail. A run with only node or jsdom projects never takes it. The holder is `<name> vitest browser`, `<name>` from the nearest `package.json`. A run nested under a holder (`local-ci run -- pnpm test`, a `pnpm check` that local-ci runs) goes ahead without waiting. Projects that each list the setup share one lock, even through separate copies of the module, so a run takes it once. Ctrl-C, SIGTERM or SIGHUP releases it and ends the run; a run killed outright is taken over as a dead holder. Watch mode takes no lock, so a watcher left open never blocks the machine's checks; agents and scripts, with no TTY, get run mode. It needs vitest 3 or later, whose setup sees the run's projects.
|
|
123
123
|
|
|
124
124
|
Part of [jonmilner/config](https://github.com/jonmilner/config#readme).
|
package/dist/vitest-entry.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ export interface BrowserLockProject {
|
|
|
24
24
|
export declare const browserLockSetup: string;
|
|
25
25
|
/**
|
|
26
26
|
* Adds the browser lock to a vitest config's root `test.globalSetup`, which vitest runs once per
|
|
27
|
-
* run. `defineConfig
|
|
27
|
+
* run. Pass it `defineConfig`'s result, `withBrowserLock(defineConfig({ test: { projects: [...] } }))`:
|
|
28
|
+
* `T`'s constraint rejects a `test` object literal with other keys, such as `projects`.
|
|
28
29
|
*/
|
|
29
30
|
export declare function withBrowserLock<T extends {
|
|
30
31
|
test?: {
|
package/dist/vitest-entry.js
CHANGED
|
@@ -8,7 +8,8 @@ import { lockCheck } from "./check-lock.js";
|
|
|
8
8
|
export const browserLockSetup = fileURLToPath(import.meta.url);
|
|
9
9
|
/**
|
|
10
10
|
* Adds the browser lock to a vitest config's root `test.globalSetup`, which vitest runs once per
|
|
11
|
-
* run. `defineConfig
|
|
11
|
+
* run. Pass it `defineConfig`'s result, `withBrowserLock(defineConfig({ test: { projects: [...] } }))`:
|
|
12
|
+
* `T`'s constraint rejects a `test` object literal with other keys, such as `projects`.
|
|
12
13
|
*/
|
|
13
14
|
export function withBrowserLock(config) {
|
|
14
15
|
const setup = config.test?.globalSetup;
|