Skip to content

Commit

Permalink
fix: ensure path correctness
Browse files Browse the repository at this point in the history
Previously we assumed that all args, that did not match any of our
defined options, was paths which should be restructured. This lead to
issues like #81 where a option was parsed as a path and the user isnt
informed.

Now the `cli` ensures that all paths is either a existing path or a
glob.
  • Loading branch information
sQVe committed Feb 27, 2020
1 parent 183ed70 commit f22f07f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import chalk from "chalk";
import fs from "fs";
import glob from "glob";
import { cosmiconfigSync } from "cosmiconfig";

import logger from "./shared/logger";
Expand Down Expand Up @@ -64,8 +66,11 @@ const parseArgs = (args: string[]): Args =>
case "--write":
acc.options.write = true;
break;
default:
acc.rootPaths.push(arg);
default: {
if (fs.existsSync(arg) || glob.hasMagic(arg)) {
acc.rootPaths.push(arg);
}
}
}

return acc;
Expand Down

0 comments on commit f22f07f

Please sign in to comment.