2021-07-15 15:26:36 +00:00
|
|
|
// Guess the OS
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
guessFromFilename(inputFile) {
|
2021-07-16 06:30:07 +00:00
|
|
|
let fn = path.basename(inputFile)
|
2021-07-15 15:26:36 +00:00
|
|
|
if (fn.match(/linux/)) {
|
|
|
|
return 'linux'
|
|
|
|
} else if (fn.match(/mac/)) {
|
|
|
|
return 'darwin'
|
|
|
|
} else if (fn.match(/darwin/)) {
|
|
|
|
return 'darwin'
|
|
|
|
} else if (fn.match(/win/)) {
|
|
|
|
return 'win32'
|
|
|
|
} else {
|
2021-07-16 15:26:43 +00:00
|
|
|
let ext = path.extname(inputFile).toLowerCase()
|
|
|
|
if (ext == '.dmg') {return 'darwin'}
|
|
|
|
if (ext == '.exe') {return 'win32'}
|
|
|
|
if (['.deb', '.appimage', '.pacman'].indexOf(ext) !== -1) {
|
2021-07-16 06:30:07 +00:00
|
|
|
return 'linux'
|
|
|
|
}
|
2021-07-15 15:26:36 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2021-07-16 15:10:30 +00:00
|
|
|
guessArch(filename, entries) {
|
|
|
|
return 'x64';
|
|
|
|
},
|
2021-07-15 15:26:36 +00:00
|
|
|
guessFromContents(entries) {
|
|
|
|
for (i in entries) {
|
|
|
|
let entry = entries[i]
|
|
|
|
if (path.extname(entry.file) == ".so") {
|
|
|
|
return 'linux'
|
|
|
|
} else if (path.extname(entry.file) == '.dll') {
|
|
|
|
return 'win32'
|
|
|
|
} else if (path.extname(entry.file) == '.dylib') {
|
|
|
|
return 'darwin'
|
|
|
|
} else if (path.extname(entry.file) == '.plist') {
|
|
|
|
return 'darwin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|