|
|
|
@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
|
|
|
|
|
//公用方法
|
|
|
|
|
import { rm as removeFile } from 'node:fs/promises'; |
|
|
|
|
import { readdir, readFile } from 'node:fs/promises'; |
|
|
|
|
import path from 'node:path'; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
|
|
|
@ -65,4 +67,28 @@ export default {
@@ -65,4 +67,28 @@ export default {
|
|
|
|
|
return imgType; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
loadCustomizeConfig: async function(configFileName) { |
|
|
|
|
let configs = {}; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
let filepath = path.resolve(configFileName); |
|
|
|
|
let content = await readFile(filepath, { encoding: 'utf8' }); |
|
|
|
|
if (content) { |
|
|
|
|
configs = JSON.parse(content); |
|
|
|
|
} |
|
|
|
|
}catch(error) { |
|
|
|
|
console.error('Get config from %s failed: %s', configFileName, error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return configs; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
mergeConfigs: function(myConfig, configs) { |
|
|
|
|
for (const key in myConfig) { |
|
|
|
|
configs[key] = myConfig[key]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return configs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|