src/commands/index.ts   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 1
mnd 0
bc 0
fnc 1
bpm 0
cpm 1
noi 0
1
import commander from 'commander'
2
import fs from 'fs'
3
import path from 'path'
4
5
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6
export default function (program: typeof commander): commander.Command[] {
7
    const commands: commander.Command[] = []
8
    const loadPath = path.dirname(__filename)
9
10
    // Loop through command files
11
    fs.readdirSync(loadPath).filter(function (filename) {
12
        return (/\.js$/.test(filename) && filename !== 'index.js')
13
    }).forEach(function (filename) {
14
        // const name: string = filename.substr(0, filename.lastIndexOf('.'))
15
16
        // Require command
17
        // eslint-disable-next-line @typescript-eslint/no-var-requires
18
        const command = require(path.join(loadPath, filename))
19
20
        // Initialize command
21
        commands.push(command.default(program))
22
    })
23
24
    return commands
25
}