File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const { spawn } = require ( "child_process" ) ;
4+ const path = require ( "path" ) ;
5+ const fs = require ( "fs" ) ;
6+
7+ const isWindows = process . platform === "win32" ;
8+ const binName = isWindows ? "ccg-binary.exe" : "ccg-binary" ;
9+ const binPath = path . join ( __dirname , binName ) ;
10+
11+ if ( ! fs . existsSync ( binPath ) ) {
12+ console . error ( "Error: ccg binary not found. Please try re-installing the package." ) ;
13+ process . exit ( 1 ) ;
14+ }
15+
16+ const child = spawn ( binPath , process . argv . slice ( 2 ) , {
17+ stdio : "inherit" ,
18+ shell : false ,
19+ } ) ;
20+
21+ child . on ( "error" , ( err ) => {
22+ console . error ( `Failed to start ccg binary: ${ err . message } ` ) ;
23+ process . exit ( 1 ) ;
24+ } ) ;
25+
26+ child . on ( "exit" , ( code ) => {
27+ process . exit ( code || 0 ) ;
28+ } ) ;
Original file line number Diff line number Diff line change @@ -69,11 +69,11 @@ async function install() {
6969 const url = getDownloadUrl ( binaryName ) ;
7070 const binDir = path . join ( __dirname , "bin" ) ;
7171 const isWindows = process . platform === "win32" ;
72- const binPath = path . join ( binDir , isWindows ? "ccg.exe" : "ccg" ) ;
72+ const binPath = path . join ( binDir , isWindows ? "ccg-binary .exe" : "ccg-binary " ) ;
7373
7474 // Skip if binary already exists
7575 if ( fs . existsSync ( binPath ) ) {
76- console . log ( `ccg already installed at ${ binPath } ` ) ;
76+ console . log ( `ccg binary already installed at ${ binPath } ` ) ;
7777 return ;
7878 }
7979
@@ -105,7 +105,7 @@ async function install() {
105105 execSync ( `tar xzf "${ tarPath } " -C "${ binDir } "` , { stdio : "ignore" } ) ;
106106 fs . unlinkSync ( tarPath ) ;
107107
108- // Rename platform-specific binary to 'ccg' (e.g., ccg-darwin-arm64 -> ccg)
108+ // Rename platform-specific binary to 'ccg-binary'
109109 const extracted = path . join ( binDir , binaryName ) ;
110110 if ( fs . existsSync ( extracted ) && extracted !== binPath ) {
111111 fs . renameSync ( extracted , binPath ) ;
Original file line number Diff line number Diff line change 1717 },
1818 "license" : " MIT" ,
1919 "bin" : {
20- "ccg" : " bin/ccg"
20+ "ccg" : " bin/ccg.js "
2121 },
2222 "scripts" : {
2323 "postinstall" : " node install.js"
You can’t perform that action at this time.
0 commit comments