mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
**Description:** - Fix the Flow strip path so enum lowering does not panic on defaulted or opaque Flow enum members that do not have explicit initializers. - Close the parser and strip gaps exposed by the Hermes and React Native corpora, including static `constructor` class members, typed arrow object returns, `match` arm `=>` separators, computed class fields after typed fields, and JSX raw `>` handling. - Add a shared Flow strip regression helper, a `flow_strip_projects` integration test that runs `Compiler.process_js_file`, and pinned React Native / React Native Web Flow corpora with sync metadata and a refresh script.
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
/**
|
|
* Propagate fixture options downward before pruning empty fixture branches.
|
|
*/
|
|
function search(dirPath) {
|
|
console.log(`Searching ${dirPath}`);
|
|
|
|
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
const entryNames = entries.map((entry) => entry.name);
|
|
const isFixtureDir = dirPath.includes('fixtures');
|
|
|
|
if (isFixtureDir && entryNames.length === 1) {
|
|
fs.rmSync(dirPath, { force: true, recursive: true });
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
isFixtureDir &&
|
|
entryNames.length === 2 &&
|
|
entryNames.includes('options.json') &&
|
|
entryNames.includes('input.js')
|
|
) {
|
|
fs.rmSync(dirPath, { force: true, recursive: true });
|
|
return true;
|
|
}
|
|
|
|
const localOptionsPath = path.join(dirPath, 'options.json');
|
|
const hasLocalOptions = fs.existsSync(localOptionsPath);
|
|
let shouldDelete = true;
|
|
|
|
for (const entry of entries) {
|
|
if (!entry.isDirectory()) {
|
|
continue;
|
|
}
|
|
|
|
const childDir = path.join(dirPath, entry.name);
|
|
const childContainsOptions = !search(childDir);
|
|
if (childContainsOptions) {
|
|
shouldDelete = false;
|
|
}
|
|
|
|
const childOptionsPath = path.join(childDir, 'options.json');
|
|
if (hasLocalOptions && fs.existsSync(childDir) && !fs.existsSync(childOptionsPath)) {
|
|
fs.copyFileSync(localOptionsPath, childOptionsPath);
|
|
}
|
|
}
|
|
|
|
if (hasLocalOptions) {
|
|
shouldDelete = false;
|
|
}
|
|
|
|
if (shouldDelete && isFixtureDir) {
|
|
fs.rmSync(dirPath, { force: true, recursive: true });
|
|
}
|
|
|
|
return !hasLocalOptions;
|
|
}
|
|
|
|
search('.');
|