From 7812dc6310a6afbd0fcfb0cd7966b95ceee30dca Mon Sep 17 00:00:00 2001 From: Oskar Grunning Date: Thu, 20 Feb 2020 22:34:20 +0100 Subject: [PATCH] feat: remove detect-roots option This is no longer a necessary option due to `destiny` supporting globs and multiple paths as input. --- src/index.ts | 7 ------- src/index/getFilePaths.ts | 17 +++-------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/index.ts b/src/index.ts index bdb2d11..d592968 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,13 +10,11 @@ import { version } from "../package.json"; const { argv } = process; export type Options = { - detectRoots: boolean; help: boolean; version: boolean; }; const defaultOptions: Options = { - detectRoots: false, help: false, version: false, }; @@ -36,7 +34,6 @@ const printHelp = (exitCode: number) => { -V, --version output version number -h, --help output usage information - -dr, --detect-roots structure after the first level ` ); @@ -57,10 +54,6 @@ const parseArgs = ( case "--version": acc.options.version = true; break; - case "-dr": - case "--detect-roots": - acc.options.detectRoots = true; - break; default: acc.paths.push(arg); } diff --git a/src/index/getFilePaths.ts b/src/index/getFilePaths.ts index e22e113..19ab567 100644 --- a/src/index/getFilePaths.ts +++ b/src/index/getFilePaths.ts @@ -1,9 +1,8 @@ import glob from "glob"; import path from "path"; -import { existsSync, lstatSync, readdirSync } from "fs-extra"; +import { existsSync, lstatSync } from "fs-extra"; import logger from "../shared/logger"; -import { Options } from "../index"; const isDirectory = (filePath: string) => lstatSync(filePath).isDirectory(); const isFile = (filePath: string) => lstatSync(filePath).isFile(); @@ -20,8 +19,7 @@ const globSearch = (pattern: string) => { }; /** Recursively get all file paths. */ -export const getFilePaths = (paths: string[], options: Options) => { - let { detectRoots } = options; +export const getFilePaths = (paths: string[]) => { const files: string[][] = []; while (paths.length > 0) { @@ -39,16 +37,7 @@ export const getFilePaths = (paths: string[], options: Options) => { if (isFile(filePath)) { files.push([filePath]); } else if (isDirectory(filePath)) { - if (detectRoots) { - const childDirectories = readdirSync(path.resolve(filePath)) - .map(x => path.join(filePath, x)) - .filter(x => isDirectory(x)); - - paths.push(...childDirectories); - detectRoots = false; - } else { - paths.push(path.join(filePath, "/**/*.*")); - } + paths.push(path.join(filePath, "/**/*.*")); } } else { logger.error(`Unable to resolve the path: ${filePath}`);