Skip to content

Commit

Permalink
feat: add --doNotFollow
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 13, 2021
1 parent 97a55f1 commit 2939a7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const cli = meow(
Options
--includeOnly [String] only include modules satisfying a pattern. https://github.com/sverweij/dependency-cruiser/blob/develop/doc/cli.md#--include-only-only-include-modules-satisfying-a-pattern
--doNotFollow [String] don't cruise modules adhering to this pattern any further. https://github.com/sverweij/dependency-cruiser/blob/develop/doc/cli.md#./options-reference.md#donotfollow-dont-cruise-modules-any-further
--rootDir [Path:String] path to root dir of source code [required]
--rootBaseUrl [Path:String] if pass it, replace rootDir with rootDirBaseURL in output.
--format ["json" | "markdown"] output format. Default: json
Expand All @@ -27,7 +28,13 @@ export const cli = meow(
default: ""
},
includeOnly: {
type: "string"
type: "string",
isMultiple: true
},
doNotFollow: {
type: "string",
isMultiple: true,
default: "^node_modules"
},
format: {
type: "string",
Expand All @@ -47,7 +54,8 @@ export const run = async (
rootDir: path.resolve(process.cwd(), flags.rootDir),
rootBaseUrl: flags.rootBaseUrl,
outputFormat: flags.format as "json" | "markdown",
includeOnly: flags.includeOnly
includeOnly: flags.includeOnly,
doNotFollow: flags.doNotFollow
});
return {
stdout: flags.format === "json" ? JSON.stringify(result) : result,
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ export async function analyzeDependency({
outputFormat,
rootDir,
rootBaseUrl = "",
includeOnly
includeOnly,
doNotFollow
}: {
rootDir: string;
rootBaseUrl: string;
outputFormat: "markdown" | "json";
includeOnly?: string | string[];
doNotFollow?: string | string[];
}) {
const ROOT_DIR = rootDir;
const hasImportExpress = (dep: IDependency) => {
Expand All @@ -92,7 +94,7 @@ export async function analyzeDependency({
const ARRAY_OF_FILES_AND_DIRS_TO_CRUISE: string[] = [ROOT_DIR];
const cruiseResult: IReporterOutput = cruise(ARRAY_OF_FILES_AND_DIRS_TO_CRUISE, {
includeOnly,
doNotFollow: "^node_modules"
doNotFollow
});
if (typeof cruiseResult.output !== "object") {
throw new Error("NO OUTPUT");
Expand Down

0 comments on commit 2939a7f

Please sign in to comment.