mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
Fix for finding folders with wildcards in the path #832
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
- [#827](https://github.com/estruyf/vscode-front-matter/issues/827): Fix for `frontmatter.json` file which gets created when already present in a sub-folder
|
||||
- [#830](https://github.com/estruyf/vscode-front-matter/issues/830): Fix for using the SEO title field setting to change the title field reference
|
||||
- [#832](https://github.com/estruyf/vscode-front-matter/issues/832): Fix for finding folders with wildcards in the path
|
||||
|
||||
## [10.2.0] - 2024-06-12 - [Release notes](https://beta.frontmatter.codes/updates/v10.2.0)
|
||||
|
||||
|
||||
@@ -29,10 +29,9 @@ import { parseWinPath } from '../helpers/parseWinPath';
|
||||
import { MediaHelpers } from '../helpers/MediaHelpers';
|
||||
import { MediaListener, PagesListener, SettingsListener } from '../listeners/dashboard';
|
||||
import { DEFAULT_FILE_TYPES } from '../constants/DefaultFileTypes';
|
||||
import { Telemetry } from '../helpers/Telemetry';
|
||||
import { glob } from 'glob';
|
||||
import { mkdirAsync } from '../utils/mkdirAsync';
|
||||
import { existsAsync, isWindows } from '../utils';
|
||||
import { existsAsync, isWindows, lstatAsync } from '../utils';
|
||||
import * as l10n from '@vscode/l10n';
|
||||
import { LocalizationKey } from '../localization';
|
||||
import { Preview } from './Preview';
|
||||
@@ -828,9 +827,26 @@ export class Folders {
|
||||
|
||||
try {
|
||||
pattern = isWindows() ? parseWinPath(pattern) : pattern;
|
||||
const files = await glob(pattern, { ignore: '**/node_modules/**', dot: true });
|
||||
const allFolders = (files || []).map((file) => dirname(file));
|
||||
const uniqueFolders = [...new Set(allFolders)];
|
||||
const folders = await glob(pattern, {
|
||||
ignore: '**/node_modules/**',
|
||||
dot: true
|
||||
});
|
||||
|
||||
const onlyFolders = [];
|
||||
for (const folder of folders) {
|
||||
try {
|
||||
const stats = await lstatAsync(folder);
|
||||
if (stats.isDirectory()) {
|
||||
onlyFolders.push(folder);
|
||||
} else {
|
||||
onlyFolders.push(dirname(folder));
|
||||
}
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const uniqueFolders = [...new Set(onlyFolders)];
|
||||
Logger.verbose(`Folders:findFolders:end - ${uniqueFolders.length}`);
|
||||
return uniqueFolders;
|
||||
} catch (e) {
|
||||
|
||||
@@ -12,6 +12,7 @@ export * from './getTitleField';
|
||||
export * from './ignoreMsgCommand';
|
||||
export * from './isWindows';
|
||||
export * from './joinUrl';
|
||||
export * from './lstatAsync';
|
||||
export * from './mkdirAsync';
|
||||
export * from './readFileAsync';
|
||||
export * from './readdirAsync';
|
||||
|
||||
4
src/utils/lstatAsync.ts
Normal file
4
src/utils/lstatAsync.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { promisify } from 'util';
|
||||
import { lstat as lstatCb } from 'fs';
|
||||
|
||||
export const lstatAsync = promisify(lstatCb);
|
||||
Reference in New Issue
Block a user