Skip to content

Commit eb1dead

Browse files
authored
Merge pull request #639 from nobkd/simpler-version
simpler version import, use builtin cli text styling
2 parents 13ece9e + e96523e commit eb1dead

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

packages/nuekit/src/cli.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bun
22

3+
import { styleText } from 'node:util'
34
import { version } from './system'
45

56
// [-npe] --> [-n, -p, -e]
@@ -118,18 +119,11 @@ Examples
118119
`
119120

120121

121-
const colors = {
122-
boldwhite: str => `\x1b[1;37m${str}\x1b[0m`,
123-
gray: str => `\x1b[90m${str}\x1b[0m`,
124-
green: str => `\x1b[32m${str}\x1b[0m`,
125-
cyan: str => `\x1b[36m${str}\x1b[0m`,
126-
}
127-
128122
function format(line) {
129-
return line.match(/^\w[\w ]+$/) ? colors.boldwhite(line) // titles
130-
: '┏┃┗'.includes(line.trim()[0]) ? colors.green(line) // ascii art
131-
: line.includes('#') ? colors.cyan(line) // comments
132-
: colors.gray(line)
123+
return line.match(/^\w[\w ]+$/) ? styleText(['bold', 'white'],line) // titles
124+
: '┏┃┗'.includes(line.trim()[0]) ? styleText(['green'], line) // ascii art
125+
: line.includes('#') ? styleText(['cyan'], line) // comments
126+
: styleText(['gray'], line)
133127
}
134128

135129
export function printHelp() {

packages/nuekit/src/system.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ import { mkdir, rm } from 'node:fs/promises'
33
import { fileURLToPath } from 'node:url'
44
import { join } from 'node:path'
55

6+
import { version as pkgVersion } from '../package.json' with { type: 'json' }
67
import { compileJS } from './asset'
78

8-
async function getVersion() {
9-
const file = Bun.file(join(import.meta.dir, '../package.json'))
10-
return (await file.json()).version
11-
}
12-
13-
export const version = await getVersion()
9+
export const version = pkgVersion
1410

1511
export function getClientFiles() {
1612
return 'error hmr mount transitions'.split(' ').map(name => {

0 commit comments

Comments
 (0)