From a40c7de9cc9e18f706dc1138d4e5afe3b17fc01b Mon Sep 17 00:00:00 2001 From: hyeseong Date: Fri, 31 Oct 2025 15:53:02 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20tsup=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/index.ts | 10 +++------- tsup.config.ts | 7 +++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 68510cd..b4d9204 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -8,6 +8,8 @@ import { showHelp } from './help.js'; import fs from 'node:fs'; import path from 'node:path'; +const VERSION = process.env.COLBRUSH_VERSION || 'unknown'; + async function main() { const flags = parseFlags(); const progress = createCliProgress(); @@ -15,13 +17,7 @@ async function main() { try { if (flags.version) { - const packagePath = path.join(process.cwd(), 'package.json'); - if (fs.existsSync(packagePath)) { - const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8')); - console.log(`🎨 Colbrush v${packageJson.version}`); - } else { - console.log('🎨 Colbrush CLI'); - } + console.log(`🎨 Colbrush v${VERSION}`); process.exit(0); } diff --git a/tsup.config.ts b/tsup.config.ts index 8d6dc7c..123be94 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,4 +1,8 @@ import { defineConfig } from 'tsup'; +import { readFileSync } from 'fs'; + +const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8')); + export default defineConfig([ // Browser 엔트리 (라이브러리) { @@ -40,5 +44,8 @@ export default defineConfig([ outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.js', }), + define: { + 'process.env.COLBRUSH_VERSION': JSON.stringify(packageJson.version), + }, }, ]);