diff --git a/src/command/sync/modules/base.ts b/src/command/sync/modules/base.ts index 82b4745..b695627 100644 --- a/src/command/sync/modules/base.ts +++ b/src/command/sync/modules/base.ts @@ -68,7 +68,8 @@ export class SyncBase { if (!filename) return false; const dir = this.#dir; const file = path.join(dir, filename); - return { relative: path.relative(dir, file), absolute: file }; + const realFilename = path.basename(filename); + return { relative: path.relative(dir, file), absolute: file, filename: realFilename }; } async canDone(syncType: SyncConfigType, type?: SyncConfigType) { if (syncType === 'sync') return true; diff --git a/src/command/sync/sync.ts b/src/command/sync/sync.ts index 9a6cbfd..cbb1c09 100644 --- a/src/command/sync/sync.ts +++ b/src/command/sync/sync.ts @@ -196,7 +196,19 @@ const clone = new Command('clone') const matchList = matchObjectList .map((item2) => { const rp = sync.getRelativePath(item2.pathname); + if (!rp) return false; + if (rp.absolute.endsWith('gitignore.txt')) { + // 修改为 .gitignore + const newPath = rp.absolute.replace('gitignore.txt', '.gitignore'); + rp.absolute = newPath; + rp.relative = path.relative(sync.dir, newPath); + } else if (rp.absolute.endsWith('.dot')) { + const filename = path.basename(rp.absolute, '.dot'); + const newPath = path.join(path.dirname(rp.absolute), `.${filename}`); + rp.absolute = newPath; + rp.relative = path.relative(sync.dir, newPath); + } return { ...item2, relative: rp.relative, absolute: rp.absolute }; }) .filter((i) => i);