11import * as fs from 'fs'
22import * as path from 'path'
3- import { fileURLToPath } from 'url'
4- import { dynamicImport } from './dynamicImport.js'
3+ import { fileURLToPath } from 'url'
4+ import { dynamicImport } from './dynamicImport.js'
55
66// Helper to get __dirname equivalent in ES Modules
77const __filename = fileURLToPath ( import . meta. url )
@@ -12,7 +12,6 @@ const __dirname = path.dirname(__filename)
1212const plugins : any [ ] = [ ]
1313let pluginsLoaded = false
1414
15-
1615export async function loadPlugins ( ) {
1716 console . log ( 'loading plugins' )
1817
@@ -33,17 +32,15 @@ export async function loadPlugins() {
3332export const abortError = [
3433 'There was an error while loading plugins.' ,
3534 'Clearing all plugins and aborting custom plugin scans.' ,
36- 'Please check the logs for hints as to what may have gone wrong.'
35+ 'Please check the logs for hints as to what may have gone wrong.' ,
3736] . join ( '\n' )
3837
39-
4038export function clearCache ( ) {
4139 console . log ( 'clearing plugin cache' )
4240 pluginsLoaded = false
4341 plugins . length = 0
4442}
4543
46-
4744// exported for mocking/testing. not for actual use
4845export async function loadBuiltInPlugins ( ) {
4946 console . log ( 'Loading built-in plugins' )
@@ -62,12 +59,12 @@ export async function loadCustomPlugins() {
6259 const pluginsPath = process . cwd ( ) + '/.github/scanner-plugins/'
6360 await loadPluginsFromPath ( {
6461 readPath : pluginsPath ,
65- importPath : pluginsPath
62+ importPath : pluginsPath ,
6663 } )
6764}
6865
6966// exported for mocking/testing. not for actual use
70- export async function loadPluginsFromPath ( { readPath, importPath } : { readPath : string , importPath : string } ) {
67+ export async function loadPluginsFromPath ( { readPath, importPath} : { readPath : string ; importPath : string } ) {
7168 try {
7269 const res = fs . readdirSync ( readPath )
7370 for ( const pluginFolder of res ) {
@@ -79,6 +76,6 @@ export async function loadPluginsFromPath({ readPath, importPath }: { readPath:
7976 console . log ( 'error: ' )
8077 console . log ( e )
8178 // - throw error to handle aborting the plugin scans
82- throw ( e )
79+ throw e
8380 }
8481}
0 commit comments