active-window-shortcuts
Advanced tools
Comparing version 0.1.0 to 0.1.1
49
index.js
@@ -0,7 +1,48 @@ | ||
const path = require('path'); | ||
// const {promisify} = require('util'); | ||
const childProcess = require('child_process'); | ||
// const execFile = promisify(childProcess.execFile); | ||
// const bin = path.join(__dirname, '../main'); | ||
const parseMac = stdout => { | ||
try { | ||
const result = JSON.parse(stdout); | ||
if (result !== null) { | ||
result.platform = 'macos'; | ||
return result; | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
throw new Error('Error parsing window data'); | ||
} | ||
}; | ||
module.exports = () => { | ||
if (process.platform === 'darwin') { | ||
return require('./lib').sync(); | ||
// if (process.platform === 'darwin') { | ||
// return require('./lib').sync(); | ||
// } | ||
// throw new Error('sorry, macOS only.'); | ||
const blar = path.join(__dirname, './main') | ||
console.log({blar}) | ||
const bla = childProcess.execFileSync('/Users/philippkuehn/Projekte/active-window-shortcuts/main', { | ||
encoding: 'utf8', | ||
// cwd: process.cwd(), | ||
}) | ||
// console.log({bla}) | ||
return parseMac(bla) | ||
return { | ||
app: 'nope', | ||
shortcuts: [], | ||
} | ||
throw new Error('sorry, macOS only.'); | ||
}; |
'use strict'; | ||
const path = require('path'); | ||
const {promisify} = require('util'); | ||
// const {promisify} = require('util'); | ||
const childProcess = require('child_process'); | ||
const execFile = promisify(childProcess.execFile); | ||
// const execFile = promisify(childProcess.execFile); | ||
const bin = path.join(__dirname, '../main'); | ||
@@ -22,7 +22,24 @@ | ||
module.exports = async () => { | ||
const {stdout} = await execFile(bin); | ||
return parseMac(stdout); | ||
// module.exports = async () => { | ||
// const {stdout} = await execFile(bin); | ||
// return parseMac(stdout); | ||
// }; | ||
// module.exports.sync = () => parseMac(childProcess.execFileSync(bin, {encoding: 'utf8'})); | ||
module.exports.sync = () => { | ||
// return parseMac() | ||
console.log(process.cwd(), __dirname, {bin}) | ||
const bla = childProcess.execFileSync('../main', { | ||
encoding: 'utf8', | ||
cwd: process.cwd(), | ||
}) | ||
console.log({bla}) | ||
return { | ||
app: 'nope', | ||
shortcuts: [], | ||
} | ||
}; | ||
module.exports.sync = () => parseMac(childProcess.execFileSync(bin, {encoding: 'utf8'})); |
{ | ||
"name": "active-window-shortcuts", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Philipp Kühn", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
80159
71
3