-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(duplicated-defaults-keys): Fix Duplicated Default Keys Assigned v…
…ia Object.assigbn (#217) * fix(duplicated-defaults-keys): I was using Winston and discovered this minor error, it's caused by modules using Object.assign to assign keys, which isn't picked up by the current filter * fix(fs): Old Node needs this import instead * fix(fs): Oops, missed this function usage during my refactor * fix: Minor change, move the filtering out via Defaults * BREAKING CHANGE: This is potentially a major change, I'm uncertain if any modules or current projects actually rely upon this "bug" Please create an issue if anything is broken after this release.
- Loading branch information
Showing
18 changed files
with
13,103 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Testing/Runner/Utils/findTests.ts | ||
import { promises as fs } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { resolvePath } from './resolvePath'; | ||
|
||
interface TestFolder { | ||
testName: string; | ||
|
||
testFolderPath: string; | ||
} | ||
|
||
export async function findTestFolders(): Promise<TestFolder[]> { | ||
const testsFolderPath = resolvePath('../../Tests/', import.meta.url); | ||
|
||
const testFolders = await fs.readdir(testsFolderPath, { | ||
encoding: 'utf-8', | ||
withFileTypes: false, | ||
}); | ||
|
||
return Promise.all( | ||
testFolders.map(async (testFolderName) => { | ||
const testFolderPath = resolve(testsFolderPath, testFolderName); | ||
|
||
try { | ||
const packageJSONFile = await fs.readFile( | ||
resolve(testFolderPath, 'package.json'), | ||
); | ||
|
||
const packageJSON = JSON.parse(packageJSONFile.toString()); | ||
|
||
return { | ||
testName: packageJSON.name, | ||
testFolderPath: testFolderPath, | ||
} as TestFolder; | ||
} catch { | ||
return undefined; | ||
} | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Testing/Runner/Utils/moduleFileFinder.ts | ||
import { promises as fs } from 'fs'; | ||
import { resolvePath } from './resolvePath'; | ||
import { resolve } from 'path'; | ||
import { pathToFileURL } from 'url'; | ||
type FileMatcher = RegExp; | ||
|
||
const coreModulesDir = resolvePath('../Modules', import.meta.url); | ||
|
||
/** | ||
* Finds module files that match the fileMatcher | ||
* @param | ||
*/ | ||
export async function findModuleFiles<T>( | ||
fileMatcher: FileMatcher, | ||
rootDir: string = coreModulesDir, | ||
): Promise<T[]> { | ||
const timerKey = `findModuleFiles-${rootDir}`; | ||
|
||
console.time(timerKey); | ||
|
||
async function processDirectory(directoryPath: string): Promise<T[]> { | ||
const directoryContents = await fs.readdir(directoryPath, { | ||
encoding: 'utf-8', | ||
withFileTypes: true, | ||
}); | ||
|
||
return Promise.all( | ||
directoryContents.flatMap((directoryContent) => { | ||
const contentPath = resolve(directoryPath, directoryContent.name); | ||
|
||
if (directoryContent.isDirectory()) { | ||
return processDirectory(contentPath); | ||
} | ||
|
||
if (fileMatcher.test(directoryContent.name) === true) { | ||
return import(pathToFileURL(contentPath).href) as Promise<T>; | ||
} | ||
|
||
return []; | ||
}), | ||
); | ||
} | ||
|
||
const results = await processDirectory(rootDir); | ||
|
||
const flatResults = results.flat(50); | ||
|
||
console.timeEnd(timerKey); | ||
|
||
return flatResults; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.