Skip to content

Commit

Permalink
fixing output from customConfig (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagoar authored Oct 2, 2020
1 parent bc90e05 commit 970240c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion __tests__/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('Generate', () => {
isEmpty: false,
filepath: '/some/package.json',
config: {
output: 'CODEOWNERS',
output: '.github/CODEOWNERS',
useMaintainers: true,
includes: ['dir1/*', 'dir2/*', 'dir5/*', 'dir6/*', 'dir7/*'],
},
Expand Down
10 changes: 5 additions & 5 deletions src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ interface CommandGenerate extends Command {
export const command = async (command: CommandGenerate): Promise<void> => {
const globalOptions = await getGlobalOptions(command);

const { output, verifyPaths, useMaintainers } = command;
const { verifyPaths, useMaintainers } = command;

const { output = globalOptions.output || path.join(__dirname, OUTPUT) } = command;

const loader = ora('generating codeowners...').start();

Expand All @@ -81,12 +83,10 @@ export const command = async (command: CommandGenerate): Promise<void> => {
try {
const ownerRules = await generate({ rootDir: __dirname, verifyPaths, useMaintainers, ...globalOptions });

const outputFile = output || path.join(__dirname, OUTPUT);

if (ownerRules.length) {
await createOwnersFile(outputFile, ownerRules);
await createOwnersFile(output, ownerRules);

loader.stopAndPersist({ text: `CODEOWNERS file was created! location: ${outputFile}`, symbol: SUCCESS_SYMBOL });
loader.stopAndPersist({ text: `CODEOWNERS file was created! location: ${output}`, symbol: SUCCESS_SYMBOL });
} else {
const includes = globalOptions.includes?.length ? globalOptions.includes : INCLUDES;
loader.stopAndPersist({
Expand Down
1 change: 1 addition & 0 deletions src/utils/getGlobalOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCustomConfiguration } from './getCustomConfiguration';
interface GlobalOptions {
includes?: string[];
output?: string;
}
export interface Command {
parent: Partial<GlobalOptions>;
Expand Down

0 comments on commit 970240c

Please sign in to comment.