添加 kit 子目录
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user