MCPcopy
hub / github.com/webpack/webpack / updateFile

Function updateFile

test/FileSystemInfo.unittest.js:296–315  ·  view source on GitHub ↗
(
		/** @type {IFs} */ fs,
		/** @type {string} */ filename
	)

Source from the content-addressed store, hash-verified

294 };
295
296 const updateFile = (
297 /** @type {IFs} */ fs,
298 /** @type {string} */ filename
299 ) => {
300 const oldContent = /** @type {string} */ (
301 /** @type {unknown} */ (fs.readFileSync(filename, "utf8"))
302 );
303 if (filename.endsWith(".json")) {
304 const data = JSON.parse(oldContent);
305 fs.writeFileSync(
306 filename,
307 JSON.stringify({
308 ...data,
309 version: `${data.version}.1`
310 })
311 );
312 } else {
313 fs.writeFileSync(filename, `${oldContent}!`);
314 }
315 };
316
317 for (const [name, options] of /** @type {[string, SnapshotOptions][]} */ ([
318 ["timestamp", { timestamp: true }],

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected