添加 kit 子目录

This commit is contained in:
Cheney
2024-03-07 15:50:13 +08:00
parent e0c2ab8c1e
commit 5fd50792a0
24 changed files with 3143 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
const os = require('os');
const fs = require("fs");
const Windows = 0;
const Linux = 1;
module.exports = {
Windows, Linux,
/**
* 根据 os 不同,载入不同的方法
*/
choise : function ( cbs ) {
if (os.type() == 'Windows_NT') {
// windows平台
return cbs && cbs[ Windows ]
}
else if (os.type() == 'Linux') {
// Linux平台
return cbs && cbs[ Linux ]
}
else {
throw { message : "不支持的 OS" }
}
},
cur : function () {
let isLinux = false;
// 操作系统不同,安装方式不同
let curOS = os.type()
if ( curOS === "Windows_NT" ) {
curOS = "Windows"
}
else if ( curOS === "Linux" ) {
isLinux = true;
const fs = require('fs');
if( fs.existsSync('/etc/alpine-release') ){
curOS = "Alpine"
}
}
let curPlatform = os.arch()
if ( curPlatform === "x64" ) {
curPlatform = "X86_64"
} else if ( curPlatform.startsWith("arm") ) {
curPlatform = "ARM64"
}
return { isLinux, curOS, curPlatform }
}
}