@@ -2,7 +2,7 @@ import { access } from 'node:fs/promises';
22import { join } from 'node:path' ;
33import { type ExecaError , execa } from 'execa' ;
44
5- export interface PlanOptions {
5+ export type PlanOptions = {
66 old : string ;
77 new : string ;
88 includes ?: string [ ] ;
@@ -12,23 +12,23 @@ export interface PlanOptions {
1212 dryRun ?: boolean ;
1313 renameFiles ?: boolean ;
1414 renameDirs ?: boolean ;
15- }
15+ } ;
1616
17- export interface ApplyOptions {
17+ export type ApplyOptions = {
1818 planId ?: string ;
1919 planPath ?: string ;
2020 atomic ?: boolean ;
2121 commit ?: boolean ;
22- }
22+ } ;
2323
24- export interface PreviewOptions {
24+ export type PreviewOptions = {
2525 planId ?: string ;
2626 planPath ?: string ;
2727 format ?: 'table' | 'diff' | 'json' | 'summary' ;
28- }
28+ } ;
2929
3030export class RenamifyService {
31- private renamifyPath : string ;
31+ private readonly renamifyPath : string ;
3232
3333 constructor ( renamifyPath ?: string ) {
3434 // Default to 'renamify' which should be in PATH
@@ -70,23 +70,23 @@ export class RenamifyService {
7070 }
7171
7272 private addIncludeArgs ( args : string [ ] , includes ?: string [ ] ) : void {
73- if ( includes && includes . length > 0 ) {
73+ if ( includes ? .length ) {
7474 for ( const pattern of includes ) {
7575 args . push ( '--include' , pattern ) ;
7676 }
7777 }
7878 }
7979
8080 private addExcludeArgs ( args : string [ ] , excludes ?: string [ ] ) : void {
81- if ( excludes && excludes . length > 0 ) {
81+ if ( excludes ? .length ) {
8282 for ( const pattern of excludes ) {
8383 args . push ( '--exclude' , pattern ) ;
8484 }
8585 }
8686 }
8787
8888 private addStylesArg ( args : string [ ] , styles ?: string [ ] ) : void {
89- if ( styles && styles . length > 0 ) {
89+ if ( styles ? .length ) {
9090 args . push ( '--styles' , styles . join ( ',' ) ) ;
9191 }
9292 }
@@ -165,15 +165,23 @@ export class RenamifyService {
165165 /**
166166 * Undo a renaming
167167 */
168- async undo ( id : string ) : Promise < string > {
169- return await this . executeCommand ( [ 'undo' , id ] , 'undo' ) ;
168+ async undo ( id ?: string ) : Promise < string > {
169+ const args = [ 'undo' ] ;
170+ if ( id ) {
171+ args . push ( id ) ;
172+ }
173+ return await this . executeCommand ( args , 'undo' ) ;
170174 }
171175
172176 /**
173177 * Redo a renaming
174178 */
175- async redo ( id : string ) : Promise < string > {
176- return await this . executeCommand ( [ 'redo' , id ] , 'redo' ) ;
179+ async redo ( id ?: string ) : Promise < string > {
180+ const args = [ 'redo' ] ;
181+ if ( id ) {
182+ args . push ( id ) ;
183+ }
184+ return await this . executeCommand ( args , 'redo' ) ;
177185 }
178186
179187 /**
0 commit comments