MCPcopy Index your code
hub / github.com/webpack/webpack-dev-server / readFile

Method readFile

lib/Server.js:1116–1136  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

1114 * @returns {string | Buffer | undefined} content of file
1115 */
1116 const readFile = (item) => {
1117 if (
1118 Buffer.isBuffer(item) ||
1119 (typeof item === "object" && item !== null && !Array.isArray(item))
1120 ) {
1121 return item;
1122 }
1123
1124 if (item) {
1125 let stats = null;
1126
1127 try {
1128 stats = fs.lstatSync(fs.realpathSync(item)).isFile();
1129 } catch {
1130 // Ignore error
1131 }
1132
1133 // It is a file
1134 return stats ? fs.readFileSync(item) : item;
1135 }
1136 };
1137
1138 /** @type {EXPECTED_ANY} */
1139 (serverOptions)[property] = Array.isArray(value)

Callers 2

normalizeOptionsMethod · 0.80
extendTypesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected