@putout/operator-filesystem 10.5.0 → 10.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/filesystem.js +12 -5
- package/package.json +1 -1
package/lib/filesystem.js
CHANGED
|
@@ -446,24 +446,31 @@ export function getRootDirectory(path) {
|
|
|
446
446
|
|
|
447
447
|
export function getFile(directoryPath, name, {type} = {}) {
|
|
448
448
|
const names = maybeArray(name);
|
|
449
|
-
const files =
|
|
449
|
+
const files = new Map();
|
|
450
|
+
let count = 0;
|
|
451
|
+
|
|
452
|
+
for (const name of names)
|
|
453
|
+
files.set(name, null);
|
|
450
454
|
|
|
451
455
|
for (const currentFile of readDirectory(directoryPath)) {
|
|
452
456
|
const currentName = getFilename(currentFile);
|
|
457
|
+
const base = basename(currentName);
|
|
453
458
|
|
|
454
|
-
if (!names.includes(
|
|
459
|
+
if (!names.includes(base))
|
|
455
460
|
continue;
|
|
456
461
|
|
|
457
462
|
if (type && type !== getFileType(currentFile))
|
|
458
463
|
continue;
|
|
459
464
|
|
|
460
|
-
files.
|
|
465
|
+
files.set(base, currentFile);
|
|
466
|
+
|
|
467
|
+
++count;
|
|
461
468
|
|
|
462
|
-
if (names.length ===
|
|
469
|
+
if (names.length === count)
|
|
463
470
|
break;
|
|
464
471
|
}
|
|
465
472
|
|
|
466
|
-
return files;
|
|
473
|
+
return files.values();
|
|
467
474
|
}
|
|
468
475
|
|
|
469
476
|
export const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-filesystem",
|
|
3
|
-
"version": "10.5.
|
|
3
|
+
"version": "10.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout operator adds ability to filesystem referenced variables that was not defined",
|