From e2b5b3e1ed9c279382bdeae6976850518fa478c1 Mon Sep 17 00:00:00 2001 From: Torathion Date: Wed, 22 Jan 2025 11:02:51 +0100 Subject: [PATCH] dev: lint --- src/index.ts | 19 ++++++++----------- src/utils.ts | 9 +++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index bc169e4..6ef8f83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,12 +116,12 @@ function processPatterns( const newPattern = normalizePattern(pattern, expandDirectories, cwd, properties, false); matchPatterns.push(newPattern); const split = newPattern.split('/'); - let splitSize = split.length + let splitSize = split.length; if (split[splitSize - 1] === '**') { if (split[splitSize - 2] !== '..') { split[splitSize - 2] = '**'; split.pop(); - splitSize-- + splitSize--; } transformed.push(splitSize ? split.join('/') : '*'); } else { @@ -184,7 +184,7 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) { }; const processed = processPatterns(options, cwd, properties); - const nocase = options.caseSensitiveMatch === false + const nocase = options.caseSensitiveMatch === false; const matcher = picomatch(processed.match, { dot: options.dot, @@ -216,7 +216,7 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) { const matches = matcher(path); if (matches) { - log(`matched ${path}`) + log(`matched ${path}`); } return matches; @@ -229,7 +229,7 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) { const skipped = ignore(relativePath) || exclude(relativePath); if (!skipped) { - log(`crawling ${p}`) + log(`crawling ${p}`); } return skipped; @@ -266,18 +266,15 @@ function crawl(options: GlobOptions, cwd: string, sync: boolean) { } // backslashes are removed so that inferred roots like `C:/New folder \\(1\\)` work - const root = properties.root = properties.root.replace(/\\/g, ''); + properties.root = properties.root.replace(/\\/g, ''); + const root = properties.root; const api = new fdir(fdirOptions).crawl(root); if (cwd === root || options.absolute) { return sync ? api.sync() : api.withPromise(); } - return sync - ? formatPaths(api.sync(), cwd, root) - : api - .withPromise() - .then(paths => formatPaths(paths, cwd, root)); + return sync ? formatPaths(api.sync(), cwd, root) : api.withPromise().then(paths => formatPaths(paths, cwd, root)); } export function glob(patterns: string | string[], options?: Omit): Promise; diff --git a/src/utils.ts b/src/utils.ts index 4151863..f85ba89 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ import picomatch from 'picomatch'; -const isWin = process.platform === 'win32' +const isWin = process.platform === 'win32'; // #region convertPathToPattern const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g; @@ -12,8 +12,9 @@ export function convertWin32PathToPattern(path: string): string { return escapeWin32Path(path).replace(ESCAPED_WIN32_BACKSLASHES, '/'); } -export const convertPathToPattern: (path: string) => string = - isWin ? convertWin32PathToPattern : convertPosixPathToPattern; +export const convertPathToPattern: (path: string) => string = isWin + ? convertWin32PathToPattern + : convertPosixPathToPattern; // #endregion // #region escapePath @@ -62,6 +63,6 @@ export function isDynamicPattern(pattern: string, options?: { caseSensitiveMatch * @param task - the current task. */ export function log(task: string): void { - console.log(`[tinyglobby ${new Date().toLocaleTimeString('es')}] ${task}`) + console.log(`[tinyglobby ${new Date().toLocaleTimeString('es')}] ${task}`); } // #endregion