1 Star 0 Fork 0

DSX/stool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
constants.js 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
const fs = require('fs');
const path = require('path');
const DEFAULT_SERVICE_PARAMS = ["appAccessMode", "appName", "comment", "displayName", "enName", "id", "templateId", "timeout"];
const DATATYPES = ["STRING", "INTEGER", "LONG", "FLOAT", "DOUBLE", "BOOLEAN"];
const DATATYPE_DEFAULT_VALUE = {
"STRING": "",
"INTEGER": "0",
"LONG": "0",
"FLOAT": "0",
"DOUBLE": "0",
"BOOLEAN": "false"
}
const SUPOS_DIR_NAME = ".supos";
const SERVICES = "services";
const CONTROLS = "controls";
const EXTENSIONS = "extensions";
function findSupOSDirectory(startPath) {
let currentDir = startPath;
// 解析当前工作目录
const parsedPath = path.parse(startPath);
const rootDir = parsedPath.root;
while (!fs.existsSync(path.join(currentDir, SUPOS_DIR_NAME))) {
if (currentDir === rootDir) {
return null;
}
currentDir = path.dirname(currentDir); // 上移一级目录
}
return currentDir; // 返回找到的目录所在的路径
}
const startingPoint = process.cwd(); // 当前工作目录作为起始点
const SUPOS_WORK_DIR = findSupOSDirectory(startingPoint);
const SUPOS_DIR = path.join(SUPOS_WORK_DIR ? SUPOS_WORK_DIR : startingPoint, SUPOS_DIR_NAME);
const SUPOS_SERVICES = path.join(SUPOS_WORK_DIR ? SUPOS_WORK_DIR : startingPoint, SERVICES);
const SUPOS_EXTENSIONS = path.join(SUPOS_WORK_DIR ? SUPOS_WORK_DIR : startingPoint, EXTENSIONS);
const ENVRC = path.join(SUPOS_WORK_DIR ? SUPOS_WORK_DIR : startingPoint, '.env');
require("dotenv").config({ override: true,path:ENVRC })
let ROOTPATH = __dirname;
module.exports = {
SUPOS_WORK_DIR,
ROOTPATH,
ENVRC,
SUPOS_DIR,
SUPOS_SERVICES,
CONTROLS,
SUPOS_EXTENSIONS,
SUPOS_DIR_NAME,
DEFAULT_SERVICE_PARAMS,
SUPOS_DIR,
DATATYPES,
DATATYPE_DEFAULT_VALUE
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Cyluone/stool.git
git@gitee.com:Cyluone/stool.git
Cyluone
stool
stool
main

搜索帮助