Skip to content

Commit 7812dc6

Browse files
committed
feat: remove detect-roots option
This is no longer a necessary option due to `destiny` supporting globs and multiple paths as input.
1 parent 758b353 commit 7812dc6

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

src/index.ts

-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import { version } from "../package.json";
1010
const { argv } = process;
1111

1212
export type Options = {
13-
detectRoots: boolean;
1413
help: boolean;
1514
version: boolean;
1615
};
1716

1817
const defaultOptions: Options = {
19-
detectRoots: false,
2018
help: false,
2119
version: false,
2220
};
@@ -36,7 +34,6 @@ const printHelp = (exitCode: number) => {
3634
3735
-V, --version output version number
3836
-h, --help output usage information
39-
-dr, --detect-roots structure after the first level
4037
`
4138
);
4239

@@ -57,10 +54,6 @@ const parseArgs = (
5754
case "--version":
5855
acc.options.version = true;
5956
break;
60-
case "-dr":
61-
case "--detect-roots":
62-
acc.options.detectRoots = true;
63-
break;
6457
default:
6558
acc.paths.push(arg);
6659
}

src/index/getFilePaths.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import glob from "glob";
22
import path from "path";
3-
import { existsSync, lstatSync, readdirSync } from "fs-extra";
3+
import { existsSync, lstatSync } from "fs-extra";
44

55
import logger from "../shared/logger";
6-
import { Options } from "../index";
76

87
const isDirectory = (filePath: string) => lstatSync(filePath).isDirectory();
98
const isFile = (filePath: string) => lstatSync(filePath).isFile();
@@ -20,8 +19,7 @@ const globSearch = (pattern: string) => {
2019
};
2120

2221
/** Recursively get all file paths. */
23-
export const getFilePaths = (paths: string[], options: Options) => {
24-
let { detectRoots } = options;
22+
export const getFilePaths = (paths: string[]) => {
2523
const files: string[][] = [];
2624

2725
while (paths.length > 0) {
@@ -39,16 +37,7 @@ export const getFilePaths = (paths: string[], options: Options) => {
3937
if (isFile(filePath)) {
4038
files.push([filePath]);
4139
} else if (isDirectory(filePath)) {
42-
if (detectRoots) {
43-
const childDirectories = readdirSync(path.resolve(filePath))
44-
.map(x => path.join(filePath, x))
45-
.filter(x => isDirectory(x));
46-
47-
paths.push(...childDirectories);
48-
detectRoots = false;
49-
} else {
50-
paths.push(path.join(filePath, "/**/*.*"));
51-
}
40+
paths.push(path.join(filePath, "/**/*.*"));
5241
}
5342
} else {
5443
logger.error(`Unable to resolve the path: ${filePath}`);

0 commit comments

Comments
 (0)