mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 10:17:26 +00:00
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
const problems = Object.values(JSON.parse(fs.readFileSync('.attw.json', 'utf-8')).problems)
|
|
.flat()
|
|
.filter(
|
|
(problem) =>
|
|
!(
|
|
// This is intentional, if the user specifies .mjs they get ESM.
|
|
(
|
|
(problem.kind === 'CJSResolvesToESM' && problem.entrypoint.endsWith('.mjs')) ||
|
|
// This is intentional for backwards compat reasons.
|
|
(problem.kind === 'MissingExportEquals' && problem.implementationFileName.endsWith('/index.js')) ||
|
|
// this is intentional, we deliberately attempt to import types that may not exist from parent node_modules
|
|
// folders to better support various runtimes without triggering automatic type acquisition.
|
|
(problem.kind === 'InternalResolutionError' && problem.moduleSpecifier.includes('node_modules'))
|
|
)
|
|
),
|
|
);
|
|
fs.unlinkSync('.attw.json');
|
|
if (problems.length) {
|
|
process.stdout.write('The types are wrong!\n' + JSON.stringify(problems, null, 2) + '\n');
|
|
process.exitCode = 1;
|
|
} else {
|
|
process.stdout.write('Types ok!\n');
|
|
}
|