Commit 420dc88a authored by David Sveningsson's avatar David Sveningsson

feat(cli): support setting cwd when calling expandFiles

parent edab9cfb
import glob from "glob";
interface ExpandOptions {
cwd?: string;
}
/**
* Takes a number of file patterns (globs) and returns array of expanded
* filenames.
*/
export function expandFiles(patterns: string[]): string[] {
export function expandFiles(
patterns: string[],
options: ExpandOptions = {}
): string[] {
const cwd = options.cwd || process.cwd();
const files = patterns.reduce((files: string[], pattern: string) => {
/* process - as standard input */
if (pattern === "-") {
pattern = "/dev/stdin";
}
return files.concat(glob.sync(pattern));
return files.concat(glob.sync(pattern, { cwd }));
}, []);
/* only return unique matches */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment