react/compiler/scripts/copyright.js
Joe Savona 90348cc873 [housekeeping] Remove disabled test262 setup
I sincerely appreciate the effort to get test262 up and running. This was my 
idea, it seemed like a really good way to test our correctness on edge cases of 
JS. Unfortunately test262 relies heavily on a few specific features that we 
don't support, like classes and `var`, which has meant that we never actually 
use this as a test suite. 

In the meantime we've created a pretty extensive test suite and have tools like 
Sprout to test actual memoization behavior at runtime, which is the right place 
to invest our energy. Let's remove?
2024-01-12 12:26:30 -08:00

71 lines
1.7 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
const fs = require("fs");
const glob = require("glob");
const META_COPYRIGHT_COMMENT_BLOCK =
`/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/`.trim() + "\n\n";
const files = glob.sync("**/*.{js,ts,tsx,jsx}", {
ignore: [
"**/dist/**",
"**/node_modules/**",
"react/**",
"forget-feedback/**",
"packages/js-fuzzer/**",
"**/tests/fixtures/**",
"**/__tests__/fixtures/**",
// Special case where we need to preserve a jest directive
"packages/forest-runtime/src/__tests__/DOM-test.ts",
],
});
const updatedFiles = new Map();
let hasErrors = false;
files.forEach((file) => {
try {
const result = processFile(file);
if (result != null) {
updatedFiles.set(file, result);
}
} catch (e) {
console.error(e);
hasErrors = true;
}
});
if (hasErrors) {
console.error("Update failed");
process.exit(1);
} else {
for (const [file, source] of updatedFiles) {
fs.writeFileSync(file, source, "utf8");
}
console.log("Update complete");
}
function processFile(file) {
let source = fs.readFileSync(file, "utf8");
if (source.indexOf(META_COPYRIGHT_COMMENT_BLOCK) === 0) {
return null;
}
if (/^\/\*\*/.test(source)) {
source = source.replace(/\/\*\*[^\/]+\/\s+/, META_COPYRIGHT_COMMENT_BLOCK);
} else {
source = `${META_COPYRIGHT_COMMENT_BLOCK}${source}`;
}
return source;
}