nuxt-dev-ready 1.0.0 → 1.1.0

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 CHANGED
@@ -70,7 +70,7 @@ $ yarn add nuxt-dev-ready
70
70
  ## Usage
71
71
 
72
72
  ```js
73
- import { execaCommand } from 'execa'
73
+ import { execaCommand } from 'execa'
74
74
  import kill from 'tree-kill-promise'
75
75
  import nuxtDevReady from 'nuxt-dev-ready'
76
76
 
@@ -87,6 +87,24 @@ try {
87
87
 
88
88
  Note that `nuxt-dev-ready` loads the Nuxt config if available.
89
89
 
90
+ ## Options
91
+
92
+ You can pass a custom port to `nuxtDevReady` in case it cannot be read from the config:
93
+
94
+ ```js
95
+ import { execaCommand } from 'execa'
96
+ import kill from 'tree-kill-promise'
97
+ import nuxtDevReady from 'nuxt-dev-ready'
98
+
99
+ const nuxt = execaCommand('nuxt dev', { env: { PORT: 4000 } })
100
+
101
+ try {
102
+ await nuxtDevReady({ port: 4000 })
103
+ } finally {
104
+ await kill(nuxt.pid)
105
+ }
106
+ ```
107
+
90
108
  <!-- LICENSE/ -->
91
109
  ## Contribute
92
110
 
package/dist/index.js CHANGED
@@ -2,8 +2,9 @@ import { loadNuxtConfig } from '@nuxt/kit';
2
2
  import axios from 'axios';
3
3
  import pWaitFor from 'p-wait-for';
4
4
  import portReady from 'port-ready';
5
- export default (async () => {
5
+ export default (async (options = {}) => {
6
6
  const config = await loadNuxtConfig();
7
+ config.devServer.port = options.port || config.devServer.port;
7
8
  // See https://github.com/nuxt/nuxt/blob/main/packages/test-utils/src/server.ts#L30
8
9
  await portReady(config.devServer.port);
9
10
  await pWaitFor(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-dev-ready",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Waits until the Nuxt dev server is loaded. Mainly useful for testing.",
5
5
  "repository": "dword-design/nuxt-dev-ready",
6
6
  "funding": "https://github.com/sponsors/dword-design",