Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 25 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 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 | } |