UNPKG

1.43 kBJavaScriptView Raw
1const path = require('path');
2const getCwd = require('./get-cwd');
3
4/**
5 * 获取项目临时配置文件路径
6 * - 临时配置文件为已转换的可无忧引用的配置文件,在流程开始前自动生成,在结束后自动删除
7 * - 0.6 之前版本: 获取项目配置文件路径 (默认: /koot.js)
8 * @param {Boolean} portion 是否获取部分配置
9 * @returns {String}
10 */
11module.exports = (portion = false) => {
12 if (portion === 'client') {
13 return typeof process.env
14 .KOOT_PROJECT_CONFIG_PORTION_CLIENT_PATHNAME === 'string'
15 ? process.env.KOOT_PROJECT_CONFIG_PORTION_CLIENT_PATHNAME
16 : path.resolve(getCwd(), 'koot.js');
17 }
18 if (portion === 'client-other') {
19 return typeof process.env
20 .KOOT_PROJECT_CONFIG_PORTION_OTHER_CLIENT_PATHNAME === 'string'
21 ? process.env.KOOT_PROJECT_CONFIG_PORTION_OTHER_CLIENT_PATHNAME
22 : path.resolve(getCwd(), 'koot.js');
23 }
24 if (portion) {
25 return typeof process.env
26 .KOOT_PROJECT_CONFIG_PORTION_SERVER_PATHNAME === 'string'
27 ? process.env.KOOT_PROJECT_CONFIG_PORTION_SERVER_PATHNAME
28 : path.resolve(getCwd(), 'koot.js');
29 }
30 return typeof process.env.KOOT_PROJECT_CONFIG_FULL_PATHNAME === 'string'
31 ? process.env.KOOT_PROJECT_CONFIG_FULL_PATHNAME
32 : path.resolve(getCwd(), 'koot.js');
33};