24 lines
700 B
TypeScript
Raw Permalink Normal View History

2026-05-31 13:21:13 +02:00
import { promises as fs } from 'node:fs'
import { basename, dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import chalk from 'chalk'
import fg from 'fast-glob'
async function run() {
// fix cjs exports
const files = await fg('*.cjs', {
ignore: ['chunk-*'],
absolute: true,
cwd: resolve(dirname(fileURLToPath(import.meta.url)), '../dist'),
})
for (const file of files) {
console.log(chalk.cyan.inverse(' POST '), `Fix ${basename(file)}`)
let code = await fs.readFile(file, 'utf8')
code = code.replace('exports.default =', 'module.exports =')
code += 'exports.default = module.exports;'
await fs.writeFile(file, code)
}
}
run()