Skip to content

Commit

Permalink
use fs.readFileSync instead of an import (#13104)
Browse files Browse the repository at this point in the history
In some environments, depending on the Node version importing a `.json`
file without a `with` or `assert` doesn't work.

Let's play it safe and use an `fs.readFileSync` instead.
  • Loading branch information
RobinMalfait authored Mar 6, 2024
1 parent 0a2b319 commit 19fcd0e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/@tailwindcss-cli/src/utils/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import fs from 'node:fs'
import path from 'node:path'
import pc from 'picocolors'
import { version } from 'tailwindcss/package.json'
import { resolve } from '../utils/resolve'
import { formatNanoseconds } from './format-ns'

export const UI = {
indent: 2,
}

export function header() {
let { version } = JSON.parse(fs.readFileSync(resolve('tailwindcss/package.json'), 'utf-8'))
return `${pc.italic(pc.bold(pc.blue('\u2248')))} tailwindcss ${pc.blue(`v${version}`)}`
}

Expand Down

0 comments on commit 19fcd0e

Please sign in to comment.