1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
- import fs from 'node:fs'
3
- import url from 'node:url'
4
- import path from 'node:path'
5
2
import type { EventEmitter } from 'node:events'
6
3
7
4
import { v4 as uuidv4 } from 'uuid'
@@ -21,7 +18,6 @@ import { validate, sanitizeError } from './utils.js'
21
18
import { DEFAULT_IMPLICIT_TIMEOUT , DEFAULT_PAGELOAD_TIMEOUT , DEFAULT_SCRIPT_TIMEOUT } from './constants.js'
22
19
import type { ActiveListener } from './types.js'
23
20
24
- const __dirname = path . dirname ( url . fileURLToPath ( import . meta. url ) )
25
21
const log = logger ( 'devtools' )
26
22
27
23
export default class DevToolsDriver {
@@ -38,27 +34,7 @@ export default class DevToolsDriver {
38
34
activeListeners : ActiveListener [ ] = [ ]
39
35
constructor ( browser : Browser , pages : Page [ ] ) {
40
36
this . browser = browser
41
-
42
- const dir = path . resolve ( __dirname , 'commands' )
43
- const files = fs . readdirSync ( dir ) . filter (
44
- ( file ) => (
45
- file . endsWith ( '.js' ) ||
46
- (
47
- file . endsWith ( '.ts' ) &&
48
- ! file . endsWith ( '.d.ts' )
49
- )
50
- )
51
- )
52
-
53
- for ( const filename of files ) {
54
- const commandName = path . basename ( filename , path . extname ( filename ) )
55
-
56
- if ( ! commandName ) {
57
- throw new Error ( 'Couldn\'t determine command name' )
58
- }
59
-
60
- this . commands [ commandName ] = commands [ commandName as keyof typeof commands ]
61
- }
37
+ this . commands = commands
62
38
63
39
this . initBrowser ( browser , pages )
64
40
}
0 commit comments