chore: mock os.networkInterfaces

This commit is contained in:
Igor Randjelovic
2021-03-05 18:28:00 +01:00
parent aa0daba6a5
commit 39d90d5c32
3 changed files with 47 additions and 11 deletions

View File

@@ -1,12 +1,6 @@
import os from 'os';
export function getIPS() {
// todo: perhaps mock networkInterfaces instead?
if (__TEST__) {
// in tests we don't need the real ips
return ['127.0.0.1', '192.168.0.10'];
}
const interfaces = os.networkInterfaces();
return Object.keys(interfaces)
.map((name) => {

View File

@@ -1,15 +1,17 @@
import { merge } from 'webpack-merge';
import { addVirtualEntry, addVirtualModule } from './virtualModules'
import { getPackageJson, getProjectRootPath } from './project';
import { addCopyRule, removeCopyRule } from './copyRules';
import { determineProjectFlavor } from './flavor';
import { error, info, warn } from './log';
import { getValue } from './config';
import { getIPS } from './host'
import {
getAllDependencies,
hasDependency,
getDependencyPath,
} from './dependencies';
import { getPackageJson, getProjectRootPath } from './project';
import {
addPlatform,
getAbsoluteDistPath,
@@ -20,6 +22,7 @@ import {
getPlatformName,
} from './platform';
// intentionally populated manually
// as this generates nicer typings
// that show all the utils inline
@@ -40,15 +43,14 @@ export default {
flavor: {
determineProjectFlavor,
},
host: {
getIPS,
},
log: {
error,
info,
warn,
},
project: {
getProjectRootPath,
getPackageJson,
},
platform: {
addPlatform,
getAbsoluteDistPath,
@@ -58,4 +60,12 @@ export default {
getPlatform,
getPlatformName,
},
project: {
getProjectRootPath,
getPackageJson,
},
virtualModules: {
addVirtualEntry,
addVirtualModule
}
};