Fix: (patching old PR) Check node version and find acceptable host accordingly (#4032)
* fix: check node version and find acceptable host accordingly
* Update for Node v18.4+
* Removed unrelated changesets
* Revert "Removed unrelated changesets"
This reverts commit e77ffc0fed
.
* chore: remove duplicate changeset
Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
parent
8c08181822
commit
beddf073b5
2 changed files with 7 additions and 1 deletions
5
.changeset/strange-needles-hide.md
Normal file
5
.changeset/strange-needles-hide.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: find a hosting network differently based on Node version -- adjusted for Node v18.4+
|
|
@ -83,12 +83,13 @@ export function devStart({
|
||||||
if (networkLogging === 'host-to-expose') {
|
if (networkLogging === 'host-to-expose') {
|
||||||
network = `${networkPrefix}${dim('use --host to expose')}`;
|
network = `${networkPrefix}${dim('use --host to expose')}`;
|
||||||
} else if (networkLogging === 'visible') {
|
} else if (networkLogging === 'visible') {
|
||||||
|
const nodeVersion = Number(process.version.substring(1, process.version.indexOf(".", 5)));
|
||||||
const ipv4Networks = Object.values(os.networkInterfaces())
|
const ipv4Networks = Object.values(os.networkInterfaces())
|
||||||
.flatMap((networkInterface) => networkInterface ?? [])
|
.flatMap((networkInterface) => networkInterface ?? [])
|
||||||
.filter(
|
.filter(
|
||||||
(networkInterface) =>
|
(networkInterface) =>
|
||||||
networkInterface?.address &&
|
networkInterface?.address &&
|
||||||
networkInterface?.family === (Number(process.version.substring(1, 5)) < 18.1 ? 'IPv4' : 4)
|
networkInterface?.family === ((nodeVersion < 18 || nodeVersion >= 18.4) ? 'IPv4' : 4)
|
||||||
);
|
);
|
||||||
for (let { address } of ipv4Networks) {
|
for (let { address } of ipv4Networks) {
|
||||||
if (address.includes('127.0.0.1')) {
|
if (address.includes('127.0.0.1')) {
|
||||||
|
|
Loading…
Reference in a new issue