File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 4242 "clean" : " git clean -xdf node_modules" ,
4343 "clean-cache" : " node scripts/clean-with-deps.js clean-cache" ,
4444 "clean-hard" : " node scripts/clean-hard.js --no-install" ,
45- "clean-reinstall" : " node scripts/clean-hard.js && node scripts/link-vercel.js" ,
45+ "clean-reinstall" : " node scripts/clean-hard.js && node scripts/clean-branch.js && node scripts/link-vercel.js" ,
46+ "clean-branch" : " node scripts/clean-branch.js" ,
4647 "dedupe" : " pnpm dedupe" ,
4748 "prepare" : " husky" ,
4849 "// Compliance" : " " ,
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+ /**
3+ * SPDX-License-Identifier: MIT
4+ */
5+
6+ const { execSync } = require ( "child_process" ) ;
7+
8+ try {
9+ console . log ( "🔄 Fetching and pruning remote branches..." ) ;
10+ execSync ( "git fetch -p" , { stdio : "inherit" } ) ;
11+
12+ console . log ( "🔍 Checking for gone branches..." ) ;
13+ const output = execSync ( "git branch -vv" , { encoding : "utf8" } ) ;
14+
15+ const goneBranches = output
16+ . split ( "\n" )
17+ . filter ( ( line ) => line . includes ( ": gone]" ) )
18+ . map ( ( line ) => line . trim ( ) . split ( " " ) [ 0 ] ) ;
19+
20+ if ( goneBranches . length === 0 ) {
21+ console . log ( "✅ No gone branches found." ) ;
22+ process . exit ( 0 ) ;
23+ }
24+
25+ goneBranches . forEach ( ( branch ) => {
26+ console . log ( `🗑️ Deleting local branch: ${ branch } ` ) ;
27+ execSync ( `git branch -D ${ branch } ` , { stdio : "inherit" } ) ;
28+ } ) ;
29+
30+ console . log ( "✅ Cleanup complete." ) ;
31+ } catch ( error ) {
32+ console . error ( "❌ Error during cleanup:" , error . message ) ;
33+ process . exit ( 1 ) ;
34+ }
You can’t perform that action at this time.
0 commit comments