@@ -116,81 +116,77 @@ async function main() {
116116 const binaryName = getBinaryName ( platform ) ;
117117 const binDir = path . join ( __dirname , "bin" ) ;
118118
119- console . log ( `[uncompact] Installing ${ BINARY_NAME } for ${ platform } /${ arch } ...` ) ;
119+ process . stderr . write ( `[uncompact] Post-install setup for ${ platform } /${ arch } ...\n ` ) ;
120120
121121 if ( ! fs . existsSync ( binDir ) ) {
122122 fs . mkdirSync ( binDir , { recursive : true } ) ;
123123 }
124124
125125 const destPath = path . join ( binDir , binaryName ) ;
126126
127- if ( fs . existsSync ( destPath ) ) {
128- return ;
129- }
127+ if ( ! fs . existsSync ( destPath ) ) {
128+ const version = getPackageVersion ( ) ;
129+ let release ;
130+ try {
131+ release = await getRelease ( version ) ;
132+ } catch ( err ) {
133+ process . stderr . write ( `[uncompact] Failed to fetch release: ${ err . message } \n` ) ;
134+ process . stderr . write ( `[uncompact] You can install manually: go install github.com/${ REPO_OWNER } /${ REPO_NAME . toLowerCase ( ) } @latest\n` ) ;
135+ process . exit ( 0 ) ;
136+ }
130137
131- const version = getPackageVersion ( ) ;
132- let release ;
133- try {
134- release = await getRelease ( version ) ;
135- } catch ( err ) {
136- process . stderr . write ( `[uncompact] Failed to fetch release: ${ err . message } \n` ) ;
137- process . stderr . write ( `[uncompact] You can install manually: go install github.com/${ REPO_OWNER } /${ REPO_NAME . toLowerCase ( ) } @latest\n` ) ;
138- process . exit ( 0 ) ;
139- }
138+ const asset = release . assets . find ( ( a ) => a . name === assetName ) ;
139+ if ( ! asset ) {
140+ process . stderr . write ( `[uncompact] No binary found for ${ platform } /${ arch } in release ${ release . tag_name } \n` ) ;
141+ process . stderr . write ( `[uncompact] Available assets: ${ release . assets . map ( ( a ) => a . name ) . join ( ", " ) } \n` ) ;
142+ process . stderr . write ( `[uncompact] You can install manually: go install github.com/${ REPO_OWNER } /${ REPO_NAME . toLowerCase ( ) } @latest\n` ) ;
143+ process . exit ( 0 ) ;
144+ }
140145
141- const asset = release . assets . find ( ( a ) => a . name === assetName ) ;
142- if ( ! asset ) {
143- process . stderr . write ( `[uncompact] No binary found for ${ platform } /${ arch } in release ${ release . tag_name } \n` ) ;
144- process . stderr . write ( `[uncompact] Available assets: ${ release . assets . map ( ( a ) => a . name ) . join ( ", " ) } \n` ) ;
145- process . stderr . write ( `[uncompact] You can install manually: go install github.com/${ REPO_OWNER } /${ REPO_NAME . toLowerCase ( ) } @latest\n` ) ;
146- process . exit ( 0 ) ;
147- }
146+ process . stderr . write ( `[uncompact] Downloading ${ BINARY_NAME } ${ release . tag_name } ...\n` ) ;
148147
149- process . stderr . write ( `[uncompact] Installing ${ BINARY_NAME } ${ release . tag_name } for ${ platform } /${ arch } ...\n` ) ;
150- process . stderr . write ( `[uncompact] Downloading ${ asset . name } ...\n` ) ;
148+ let buffer ;
149+ try {
150+ buffer = await httpsGet ( asset . browser_download_url ) ;
151+ } catch ( err ) {
152+ process . stderr . write ( `[uncompact] Failed to download: ${ err . message } \n` ) ;
153+ process . exit ( 0 ) ;
154+ }
151155
152- let buffer ;
153- try {
154- buffer = await httpsGet ( asset . browser_download_url ) ;
155- } catch ( err ) {
156- process . stderr . write ( `[uncompact] Failed to download: ${ err . message } \n` ) ;
157- process . exit ( 0 ) ;
158- }
156+ process . stderr . write ( `[uncompact] Extracting...\n` ) ;
159157
160- process . stderr . write ( `[uncompact] Extracting...\n` ) ;
158+ try {
159+ if ( platform === "windows" ) {
160+ extractZip ( buffer , binDir , binaryName ) ;
161+ } else {
162+ extractTarGz ( buffer , binDir , binaryName ) ;
163+ }
164+ } catch ( err ) {
165+ process . stderr . write ( `[uncompact] Failed to extract: ${ err . message } \n` ) ;
166+ process . exit ( 0 ) ;
167+ }
161168
162- try {
163- if ( platform === "windows" ) {
164- extractZip ( buffer , binDir , binaryName ) ;
165- } else {
166- extractTarGz ( buffer , binDir , binaryName ) ;
169+ if ( platform !== "windows" ) {
170+ fs . chmodSync ( destPath , 0o755 ) ;
167171 }
168- } catch ( err ) {
169- process . stderr . write ( `[uncompact] Failed to extract: ${ err . message } \n` ) ;
170- process . exit ( 0 ) ;
171- }
172172
173- if ( platform !== "windows" ) {
174- fs . chmodSync ( destPath , 0o755 ) ;
173+ process . stderr . write ( `[uncompact] Installed to ${ destPath } \n\n` ) ;
175174 }
176175
177- process . stderr . write ( `[uncompact] Installed to ${ destPath } \n\n` ) ;
178-
179176 // Automatically install Claude Code hooks
180177 process . stderr . write ( "[uncompact] Configuring Claude Code hooks...\n" ) ;
181178 try {
182- // We redirect stdout to stderr to ensure visibility during npm install
183- execFileSync ( destPath , [ "install" , "--yes" ] , { stdio : [ "inherit" , process . stderr , "inherit" ] } ) ;
179+ // We use "inherit" for the configuration command to ensure it shows up in the terminal
180+ execFileSync ( destPath , [ "install" , "--yes" ] , { stdio : "inherit" } ) ;
184181 } catch ( err ) {
185- process . stderr . write ( "[uncompact] Failed to automatically configure hooks. You can run it manually:\n" ) ;
182+ process . stderr . write ( "[uncompact] Note: Automatic hook configuration skipped or failed. Run manually if needed :\n" ) ;
186183 process . stderr . write ( " uncompact install\n" ) ;
187184 }
188185 process . stderr . write ( "\n" ) ;
189186
190187 // Show help output after install
191188 try {
192- // We redirect stdout to stderr to ensure visibility during npm install
193- execFileSync ( destPath , [ ] , { stdio : [ "inherit" , process . stderr , "inherit" ] } ) ;
189+ execFileSync ( destPath , [ ] , { stdio : "inherit" } ) ;
194190 } catch ( err ) {
195191 // Ignore errors from running the binary itself
196192 }
0 commit comments