@@ -9,6 +9,7 @@ export interface FileEntry {
9
9
10
10
/** Sentinel used to explicitly drop a value. */
11
11
export const DROP = Symbol ( "MERGE_DROP" ) ;
12
+ export const DEFAULT_BACKUP_DIR = ".merge-backups" ;
12
13
13
14
/**
14
15
* Checks whether the given file contains Git merge conflict markers.
@@ -44,13 +45,15 @@ export const listMatchingFiles = async ({
44
45
matcher,
45
46
includeNonConflicted,
46
47
debug,
47
- backupDir,
48
+ backupDir = DEFAULT_BACKUP_DIR ,
48
49
} : CollectFilesOptions ) : Promise < FileEntry [ ] > => {
49
50
for ( const p of [ ...include , ...exclude ] ) {
50
51
if ( p . startsWith ( "!" ) ) throw new Error ( `Negation not allowed in include/exclude: ${ p } ` ) ;
51
52
if ( p . includes ( "\\" ) ) console . warn ( `Use '/' as path separator: ${ p } ` ) ;
52
53
}
53
54
55
+ exclude . push ( backupDir ) ;
56
+
54
57
const fileMatcher = ( filepath : string ) => {
55
58
const posixPath = filepath . replace ( / \\ / g, "/" ) ;
56
59
return matcher . isMatch ( posixPath , include ) && ! matcher . isMatch ( posixPath , exclude ) ;
@@ -149,7 +152,7 @@ export const createSkipDirectoryMatcher = (
149
152
} ;
150
153
} ;
151
154
152
- export const backupFile = async ( filePath : string , backupDir = ".merge-backups" ) => {
155
+ export const backupFile = async ( filePath : string , backupDir : string ) => {
153
156
const relPath = path . relative ( process . cwd ( ) , filePath ) ;
154
157
const backupPath = path . join ( backupDir , relPath ) ;
155
158
0 commit comments