fixed ykman path on macos

pull/1541/head
antelle 2020-06-04 21:33:42 +02:00
parent db38e015f8
commit 7e4e61e005
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 18 additions and 5 deletions

View File

@ -21,6 +21,19 @@ const YubiKey = {
return this._ykChalResp;
},
cmd() {
if (this._cmd) {
return this._cmd;
}
const macYkmanPath = '/usr/local/bin/ykman';
if (Launcher.platform() === 'darwin' && Launcher.fileExistsSync(macYkmanPath)) {
this._cmd = macYkmanPath;
} else {
this._cmd = 'ykman';
}
return this._cmd;
},
checkToolStatus() {
if (this.ykmanStatus === 'ok') {
return Promise.resolve(this.ykmanStatus);
@ -28,7 +41,7 @@ const YubiKey = {
return new Promise((resolve) => {
this.ykmanStatus = 'checking';
Launcher.spawn({
cmd: 'ykman',
cmd: this.cmd(),
args: ['-v'],
noStdOutLogging: true,
complete: (err, stdout, code) => {
@ -104,7 +117,7 @@ const YubiKey = {
}
this.process = Launcher.spawn({
cmd: 'ykman',
cmd: this.cmd(),
args: ['list'],
noStdOutLogging: true,
complete: (err, stdout) => {
@ -172,7 +185,7 @@ const YubiKey = {
Events.on('usb-devices-changed', onDevicesChangedDuringRepair);
Launcher.spawn({
cmd: 'ykman',
cmd: this.cmd(),
args: ['config', 'usb', '-e', 'oath', '-f'],
noStdOutLogging: true,
complete: (err) => {
@ -195,7 +208,7 @@ const YubiKey = {
this.aborted = false;
this.process = Launcher.spawn({
cmd: 'ykman',
cmd: this.cmd(),
args: ['-d', serial, 'oath', 'code'],
noStdOutLogging: true,
throwOnStdErr: true,
@ -233,7 +246,7 @@ const YubiKey = {
getOtp(serial, entry, callback) {
return Launcher.spawn({
cmd: 'ykman',
cmd: this.cmd(),
args: ['-d', serial, 'oath', 'code', '--single', entry],
noStdOutLogging: true,
complete: (err, stdout) => {