Skip to content

Commit

Permalink
feat: support .roarr.cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jul 8, 2022
1 parent e085cd7 commit 87e0990
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The "pretty" format relies on logs using the context property names suggested in

## Roarr configuration file

Roarr searches the current working directory for `.roarr.js` file. If it cannot find the configuration file, it will traverse upwards the directory tree searching for a matching configuration file and give up on a first permission error.
Roarr searches the current working directory for `.roarr.js` (or `.roarr.cjs`) file. If it cannot find the configuration file, it will traverse upwards the directory tree searching for a matching configuration file and give up on a first permission error.

`.roarr.js` is a JavaScript file that exports an object that defines properties used to configure Roarr, e.g.

Expand Down
2 changes: 1 addition & 1 deletion src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const argv = yargs

const UuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/ui;

const roarrConfigurationPath = findNearestRoarrConfigurationPath();
const roarrConfigurationPath = findNearestRoarrConfigurationPath('.roarr.cjs') ?? findNearestRoarrConfigurationPath('.roarr.js');

let filterFunction: FilterFunction | null = null;

Expand Down
6 changes: 3 additions & 3 deletions src/utilities/findNearestRoarrConfigurationPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
RoarrError,
} from '../errors';

export const findNearestRoarrConfigurationPath = (startPath: string = process.cwd()): string | null => {
export const findNearestRoarrConfigurationPath = (fileName: string, startPath: string = process.cwd()): string | null => {
let currentPath = startPath;

// eslint-disable-next-line no-constant-condition
while (true) {
const roarrConfigurationPath = path.join(currentPath, '.roarr.js');
const roarrConfigurationPath = path.join(currentPath, fileName);

try {
fs.accessSync(roarrConfigurationPath, fs.constants.F_OK);
Expand All @@ -32,7 +32,7 @@ export const findNearestRoarrConfigurationPath = (startPath: string = process.cw

return roarrConfigurationPath;
} catch {
throw new RoarrError('Found .roarr.js but do not have read permission.');
throw new RoarrError('Found ' + fileName + ' but do not have read permission.');
}
}

Expand Down

0 comments on commit 87e0990

Please sign in to comment.