nuxt-dev-ready 1.1.2 → 2.0.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 +3 -7
- package/dist/index.js +5 -12
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -53,8 +53,6 @@
|
|
|
53
53
|
Waits until the Nuxt dev server is loaded. Mainly useful for testing.
|
|
54
54
|
<!-- /DESCRIPTION -->
|
|
55
55
|
|
|
56
|
-
The logic has been taken from [@nuxt/test-utils](https://www.npmjs.com/package/@nuxt/test-utils).
|
|
57
|
-
|
|
58
56
|
<!-- INSTALL/ -->
|
|
59
57
|
## Install
|
|
60
58
|
|
|
@@ -85,11 +83,9 @@ try {
|
|
|
85
83
|
}
|
|
86
84
|
```
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## Options
|
|
86
|
+
## Custom port
|
|
91
87
|
|
|
92
|
-
You can pass a custom port to `nuxtDevReady`
|
|
88
|
+
You can pass a custom port to `nuxtDevReady` like so:
|
|
93
89
|
|
|
94
90
|
```js
|
|
95
91
|
import { execaCommand } from 'execa'
|
|
@@ -99,7 +95,7 @@ import nuxtDevReady from 'nuxt-dev-ready'
|
|
|
99
95
|
const nuxt = execaCommand('nuxt dev', { env: { PORT: 4000 } })
|
|
100
96
|
|
|
101
97
|
try {
|
|
102
|
-
await nuxtDevReady(
|
|
98
|
+
await nuxtDevReady(4000)
|
|
103
99
|
} finally {
|
|
104
100
|
await kill(nuxt.pid)
|
|
105
101
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { loadNuxtConfig } from '@nuxt/kit';
|
|
2
1
|
import axios from 'axios';
|
|
3
2
|
import pWaitFor from 'p-wait-for';
|
|
4
3
|
import portReady from 'port-ready';
|
|
5
|
-
export default (async (
|
|
6
|
-
|
|
7
|
-
config.devServer.port = options.port || config.devServer.port;
|
|
8
|
-
// See https://github.com/nuxt/nuxt/blob/main/packages/test-utils/src/server.ts#L30
|
|
9
|
-
await portReady(config.devServer.port);
|
|
4
|
+
export default (async (port = 3000) => {
|
|
5
|
+
await portReady(port);
|
|
10
6
|
await pWaitFor(async () => {
|
|
11
7
|
try {
|
|
12
|
-
|
|
13
|
-
if (!result.data.includes('__NUXT_LOADING__') && !result.data.includes('id="nuxt_loading_screen"')) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
8
|
+
await axios.get(`http://localhost:${port}`);
|
|
16
9
|
} catch (error) {
|
|
17
|
-
return error.response.status !== 503;
|
|
10
|
+
return error.code !== 'ECONNREFUSED' && error.response.status !== 503;
|
|
18
11
|
}
|
|
19
|
-
return
|
|
12
|
+
return true;
|
|
20
13
|
}, {
|
|
21
14
|
interval: 100
|
|
22
15
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-dev-ready",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Waits until the Nuxt dev server is loaded. Mainly useful for testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wait"
|
|
@@ -26,26 +26,22 @@
|
|
|
26
26
|
"test": "base test"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nuxt/kit": "^3.4.2",
|
|
30
29
|
"axios": "^1.3.6",
|
|
31
30
|
"p-wait-for": "^5.0.2",
|
|
32
31
|
"port-ready": "^0.1.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@dword-design/base": "^
|
|
34
|
+
"@dword-design/base": "^10.0.1",
|
|
36
35
|
"@dword-design/functions": "^5.0.14",
|
|
37
36
|
"execa": "^7.1.1",
|
|
38
37
|
"fs-extra": "^11.1.1",
|
|
39
|
-
"jsdom": "^
|
|
38
|
+
"jsdom": "^22.0.0",
|
|
40
39
|
"nuxt": "^3.4.2",
|
|
41
40
|
"tree-kill-promise": "^3.0.14",
|
|
42
41
|
"with-local-tmp-dir": "^5.0.1"
|
|
43
42
|
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"nuxt": "^3"
|
|
46
|
-
},
|
|
47
43
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
44
|
+
"node": ">=16"
|
|
49
45
|
},
|
|
50
46
|
"publishConfig": {
|
|
51
47
|
"access": "public"
|