get-open-apps
Advanced tools
Comparing version 1.0.6 to 1.0.7
38
index.js
module.exports = async function(opt) { | ||
opt = opt || {}; | ||
const err = console.error; | ||
@@ -7,9 +8,21 @@ const log = console.log; | ||
const path = require('path'); | ||
log(os.type()); | ||
if (os.type() == 'Windows_NT') { | ||
log('get-open-apps says hi to windows PC'); | ||
return { | ||
Atom: path.join(os.homedir().replace(/\\/g, '/'), '/AppData/Local/atom') | ||
}; | ||
let osType = os.type(); | ||
const linux = (osType == 'Linux'); | ||
const mac = (osType == 'Darwin'); | ||
const win = (osType == 'Windows_NT'); | ||
if (win) { | ||
osType = 'win'; | ||
} else if (mac) { | ||
osType = 'mac'; | ||
} else if (linux) { | ||
osType = 'linux'; | ||
} | ||
if (opt.v) { | ||
log(osType); | ||
} | ||
if (win) { | ||
log('not compatible with Windows currently!'); | ||
return {}; | ||
} | ||
const { | ||
@@ -25,9 +38,16 @@ promisify | ||
}); | ||
log(processes); | ||
if (opt.v) { | ||
log(processes); | ||
} | ||
let regex; | ||
if (mac) { | ||
regex = /(?:\/Applications)(?:\/[^\/\.]*\/|\/)*(?:([^\.]+)\.app)/; | ||
} else if (linux) { | ||
regex = /(?:(?:\/(?:snap|usr\/bin)\/)([^\/]+)|(?:\/[^\/\.]*\/)*([^\/\.]+)\.AppImage)/; | ||
} | ||
for (let i = 0; i < processes.length; i++) { | ||
let process = processes[i].command; | ||
let regex = /(?:\/Applications)(?:\/[^\/\.]*\/|\/)*(?:([^\.]+)\.app)/; | ||
let app = process.match(regex); | ||
if (app && !appsOpen[app[1]]) { | ||
appsOpen[app[1]] = app[0]; | ||
appsOpen[app[1]] = process; | ||
} | ||
@@ -34,0 +54,0 @@ } |
@@ -27,5 +27,5 @@ { | ||
"version": "git add -A", | ||
"postversion": "git remote | xargs -L1 git push --all && git push --tags && npm publish" | ||
"postversion": "git push --tags && npm publish" | ||
}, | ||
"version": "1.0.6" | ||
"version": "1.0.7" | ||
} |
8171
7
157