Skip to content

Commit

Permalink
fix: relative path name (#2675)
Browse files Browse the repository at this point in the history
Fix relative path names when reading the file list from `stdin`.
  • Loading branch information
Jason3S committed Apr 8, 2022
1 parent 42740a9 commit 51fc55b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/cspell/src/util/async.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { toAsyncIterable as mergeAsyncIterables, toArray as asyncIterableToArray } from '@cspell/cspell-pipe';
export {
toAsyncIterable as mergeAsyncIterables,
toArray as asyncIterableToArray,
opMap as asyncMap,
} from '@cspell/cspell-pipe';
10 changes: 8 additions & 2 deletions packages/cspell/src/util/fileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GlobOptions, globP } from './glob';
import * as path from 'path';
import { CSpellUserSettings, Document, fileToDocument, Issue } from 'cspell-lib';
import { IOError, toApplicationError, toError } from './errors';
import { mergeAsyncIterables } from './async';
import { mergeAsyncIterables, asyncMap } from './async';
import { readStdin } from './stdin';

const UTF8: BufferEncoding = 'utf8';
Expand Down Expand Up @@ -135,6 +135,12 @@ export function calcFinalConfigInfo(
};
}

function resolveFilename(filename: string): string {
return path.resolve(filename);
}

const resolveFilenames = asyncMap(resolveFilename);

/**
* Read
* @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
Expand All @@ -150,7 +156,7 @@ export async function readFileListFiles(listFiles: string[]): Promise<string[] |
});
const found = flatten(await Promise.all(files.map(readFileListFile)));
// Move `stdin` to the end.
return useStdin ? mergeAsyncIterables(found, readStdin()) : found;
return useStdin ? resolveFilenames(mergeAsyncIterables(found, readStdin())) : found;
}

/**
Expand Down

0 comments on commit 51fc55b

Please sign in to comment.