File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import path from "path";
44import Git from "nodegit" ;
55
66import { createQuestion } from "./util/createQuestion" ;
7+ import { isDirEmptySync } from "./util/fs" ;
78
89import { filenames } from "./filenames" ;
910import { configKeys } from "./configKeys" ;
@@ -178,7 +179,7 @@ export const markThatApplied = (pathToStackedRebaseDirInsideDotGit: string): voi
178179 // // })(),
179180 fs . existsSync ( rewrittenListPath ) && fs . unlinkSync ( rewrittenListPath ) ,
180181 fs . existsSync ( gitRebaseTodoPath ) && fs . unlinkSync ( gitRebaseTodoPath ) ,
181- fs . readdirSync ( pathToStackedRebaseDirInsideDotGit ) . length === 0 &&
182+ isDirEmptySync ( pathToStackedRebaseDirInsideDotGit ) &&
182183 fs . rmdirSync ( pathToStackedRebaseDirInsideDotGit , { recursive : true } ) ,
183184 void 0
184185 )
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { parseTodoOfStackedRebase } from "./parse-todo-of-stacked-rebase/parseTo
2222import { Termination } from "./util/error" ;
2323import { assertNever } from "./util/assertNever" ;
2424import { Single , Tuple } from "./util/tuple" ;
25+ import { isDirEmptySync } from "./util/fs" ;
2526import {
2627 GoodCommand ,
2728 GoodCommandRegular ,
@@ -463,6 +464,14 @@ export const gitStackedRebase = async (
463464 execSyncInRepo ( `${ options . editor } ${ pathToStackedRebaseTodoFile } ` ) ;
464465 }
465466 } catch ( _e ) {
467+ /**
468+ * cleanup
469+ */
470+ fs . unlinkSync ( pathToStackedRebaseTodoFile ) ;
471+ if ( isDirEmptySync ( pathToStackedRebaseDirInsideDotGit ) ) {
472+ fs . rmdirSync ( pathToStackedRebaseDirInsideDotGit , { recursive : true } ) ;
473+ }
474+
466475 throw new Termination ( `error: There was a problem with the editor '${ options . editor } '.\n` ) ;
467476 }
468477 }
Original file line number Diff line number Diff line change 1+ import fs from "fs" ;
2+
3+ export const isDirEmptySync = ( dirPath : fs . PathLike ) : boolean => fs . readdirSync ( dirPath ) . length === 0 ;
You can’t perform that action at this time.
0 commit comments