1 | const fs = require('fs-extra')
|
2 | const getPathnameProjectConfigFile = require('./get-pathname-project-config-file')
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | module.exports = async (key) => {
|
10 | const pathnameKootJS = getPathnameProjectConfigFile()
|
11 |
|
12 | try {
|
13 | const config = require(pathnameKootJS)
|
14 | return config[key]
|
15 | } catch (e) { }
|
16 |
|
17 | const content = await fs.readFile(pathnameKootJS, 'utf-8')
|
18 | const regex = new RegExp(`${key}[ ]*=[ ]*['"](.+?)['"]`, "gm")
|
19 | const matches = regex.exec(content)
|
20 |
|
21 | if (Array.isArray(matches) && matches.length > 1)
|
22 | return matches[1]
|
23 |
|
24 | return undefined
|
25 | }
|