Skip to content

Commit

Permalink
fix: 🐞 using relative and absolute paths in read ignore file
Browse files Browse the repository at this point in the history
using relative and absolute paths in read ignore file
  • Loading branch information
Tal Rofe committed Jul 8, 2022
1 parent 8e7b79a commit cb36a7a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/modules/app/utils/read-ignore-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import CLILoggerModule from '@/shared/modules/cli-logger';
import { DEFAULT_PATH } from '../models/ignore-file';

export const readIgnoreFile = async (filePath?: string) => {
const ignoreFilePath = path.join(process.cwd(), filePath ?? DEFAULT_PATH);
let absoluteIgnorePath: string;

if (!filePath) {
absoluteIgnorePath = DEFAULT_PATH;
} else {
absoluteIgnorePath = path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);
}

try {
const fileContent = await fs.readFile(ignoreFilePath, 'utf8');
const fileContent = await fs.readFile(absoluteIgnorePath, 'utf8');

return fileContent.split(/\r?\n/);
} catch {
Expand Down

0 comments on commit cb36a7a

Please sign in to comment.