diff --git a/src/config/user-config.ts b/src/config/user-config.ts index ccea2f8..2f9d3a0 100644 --- a/src/config/user-config.ts +++ b/src/config/user-config.ts @@ -42,23 +42,31 @@ export async function getUserConfig(): Promise { ...cliArguments.flags, } as ForkConfig; - const files = mergeFiles(parsedConfig.data?.files, cliArguments.flags?.files); - return { ...usersConfig, path: cwd, - files: files.length > 0 ? files : DEFAULT_CONFIG.files, + files: getFiles(parsedConfig.data?.files, cliArguments.flags?.files), changelogPresetConfig: getChangelogPresetConfig(usersConfig?.changelogPresetConfig), }; } -function mergeFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] { - return Array.from( - new Set( - ([] as string[]).concat( - Array.isArray(configFiles) ? configFiles : [], - Array.isArray(cliFiles) ? cliFiles : [], - ), - ), - ); +function getFiles(configFiles: string[] | undefined, cliFiles: string[] | undefined): string[] { + const listOfFiles = new Set(); + + // Add files from the users config file + if (Array.isArray(configFiles)) { + configFiles.forEach((file) => listOfFiles.add(file)); + } + + // Add files from the cli arguments + if (Array.isArray(cliFiles)) { + cliFiles.forEach((file) => listOfFiles.add(file)); + } + + // If the user has defined files use them, otherwise use the default list of files. + if (listOfFiles.size) { + return Array.from(listOfFiles); + } + + return DEFAULT_CONFIG.files; } diff --git a/tests/create-test-directory.ts b/tests/create-test-directory.ts index dc7d26c..c33d249 100644 --- a/tests/create-test-directory.ts +++ b/tests/create-test-directory.ts @@ -26,6 +26,7 @@ export function createTestDir(testName: string) { throw new Error(`Test folder already exists: ${testDir}`); } + execSync("git config --global init.defaultBranch main", execSyncOptions); execSync("git init", execSyncOptions); execSync("git config commit.gpgSign false", execSyncOptions); execSync("git config core.autocrlf false", execSyncOptions);