Skip to content

Commit

Permalink
fix: improve logger
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Dec 11, 2024
1 parent c54a04a commit 7a4f2af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ export async function syncCore(
return true;
}

const [destFiles, srcFiles] = await Promise.all([fs.readdir(destRepoPath), fs.readdir(srcRepoPath)]);
// Force to ignore .git directory
const ignorePatterns = [...new Set([...opts['ignore-patterns'].map(String), '.git'])];
for (const destFile of micromatch.not(destFiles, ignorePatterns)) {
let [destFiles, srcFiles] = await Promise.all([fs.readdir(destRepoPath), fs.readdir(srcRepoPath)]);
destFiles = micromatch.not(destFiles, ignorePatterns);
srcFiles = micromatch.not(srcFiles, ignorePatterns);
logger.debug('destFiles: %o', destFiles);
logger.debug('srcFiles: %o', srcFiles);
for (const destFile of destFiles) {
await fs.rm(path.join(destRepoPath, destFile), { recursive: true, force: true });
}
for (const srcFile of micromatch.not(srcFiles, ignorePatterns)) {
for (const srcFile of srcFiles) {
await copy(path.join(srcRepoPath, srcFile), path.join(destRepoPath, srcFile));
}
await dstGit.add('-A');
Expand All @@ -107,8 +111,9 @@ export async function syncCore(
? srcLog.all.map((l) => `* ${l.message}`).join('\n\n')
: `Replace all the files with those of ${opts.dest} due to missing sync commit.`;
try {
await dstGit.commit(`${title}\n\n${body}`);
logger.debug(`Created a commit: ${title}`);
const ret = await dstGit.commit(`${title}\n\n${body}`);
logger.debug(`Created a commit: %o`, ret);
logger.debug(title);
logger.debug(` with body: ${body}`);
} catch (error) {
logger.error(`Failed to commit changes: ${(error as Error).stack}`);
Expand Down
2 changes: 1 addition & 1 deletion src/yargsOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const yargsOptions = {
alias: 'i',
describe: `Exclude the files whose path matches one of the given patterns.
The patterns are processed by micromatch (https://github.com/micromatch/micromatch).
You may specify the option multiple times. Default value is "-i .git -i .github -i node_modules -i '.renovaterc.*'"`,
You may specify the option multiple times. Default value is "-i .git -i .github -i node_modules -i '.renovaterc.*' -i '.renovate.*'"`,
default: ['.git', '.github', 'node_modules', '.renovaterc.*', 'renovate.*'],
},
dry: {
Expand Down

0 comments on commit 7a4f2af

Please sign in to comment.