Total Complexity | 4 |
Complexity/F | 2 |
Lines of Code | 18 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import path from 'path'; |
||
2 | import { promisify } from 'util'; |
||
3 | import { exec } from 'child_process'; |
||
4 | import { entry } from './constants'; |
||
5 | |||
6 | const execAsync = promisify(exec); |
||
7 | |||
8 | export function load(relPath, clearCache) { |
||
9 | const absPath = path.resolve(entry, relPath); |
||
10 | |||
11 | if (clearCache) delete require.cache[require.resolve(absPath)]; |
||
12 | // eslint-disable-next-line security/detect-non-literal-require |
||
13 | const result = require(absPath); |
||
14 | |||
15 | if (clearCache) delete require.cache[require.resolve(absPath)]; |
||
16 | |||
17 | return result; |
||
18 | } |
||
19 | |||
43 |