MCPcopy Create free account
hub / github.com/babel/babel / writeFile

Function writeFile

packages/babel-compat-data/scripts/utils-build-data.mjs:189–206  ·  view source on GitHub ↗
(data, dataPath, name)

Source from the content-addressed store, hash-verified

187}
188
189export function writeFile(data, dataPath, name) {
190 const stringified = JSON.stringify(data, null, 2) + "\n";
191 if (process.env.CHECK_COMPAT_DATA) {
192 const currentData = fs.readFileSync(dataPath, "utf8");
193
194 // Compare as JSON strings to also check keys ordering
195 if (currentData !== stringified) {
196 console.error(
197 `The newly generated ${name} data does not match the current files. Re-run \`make build-compat-data\`.`
198 );
199
200 return false;
201 }
202 } else {
203 fs.writeFileSync(dataPath, stringified);
204 }
205 return true;
206}
207
208export function maybeDefineLegacyPluginAliases(data) {
209 // We create a new object to inject legacy aliases in the correct

Calls

no outgoing calls

Tested by

no test coverage detected