Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 13, 2022
1 parent 9018a97 commit aff61cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/patchCJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports.parseVueRequest = parseVueRequest;
*/

import { readFileSync, writeFileSync } from 'fs'
import { bold, red } from 'picocolors'
import colors from 'picocolors'

const indexPath = 'dist/index.cjs'
let code = readFileSync(indexPath, 'utf-8')
Expand All @@ -40,7 +40,7 @@ if (matchMixed) {

writeFileSync(indexPath, lines.join('\n'))

console.log(bold(`${indexPath} CJS patched`))
console.log(colors.bold(`${indexPath} CJS patched`))
process.exit()
}

Expand All @@ -49,9 +49,9 @@ const matchDefault = code.match(/\nmodule.exports = (\w+);/)
if (matchDefault) {
code += `module.exports["default"] = ${matchDefault[1]};\n`
writeFileSync(indexPath, code)
console.log(bold(`${indexPath} CJS patched`))
console.log(colors.bold(`${indexPath} CJS patched`))
process.exit()
}

console.error(red(`${indexPath} CJS patch failed`))
console.error(colors.red(`${indexPath} CJS patch failed`))
process.exit(1)

0 comments on commit aff61cb

Please sign in to comment.