From f45195e638953f96955ca5591acc286e980d7f1b Mon Sep 17 00:00:00 2001 From: Dave Wasmer Date: Thu, 27 Apr 2017 16:42:35 -0600 Subject: [PATCH] fix: trim newlines from discovered certutil path --- src/index.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index e83d401..1a3c314 100644 --- a/src/index.ts +++ b/src/index.ts @@ -230,18 +230,21 @@ function lookupOrInstallCertutil(installCertutil: boolean): boolean | string { debug('on mac, looking for homebrew (the only method for install nss supported by devcert'); if (commandExists('brew')) { let nssPath: string; + let certutilPath: string; try { - let certutilPath = path.join(run('brew --prefix nss').toString(), 'bin', 'certutil'); - debug(`Found nss installed at ${ certutilPath }`); - return certutilPath; + certutilPath = path.join(run('brew --prefix nss').toString().trim(), 'bin', 'certutil'); } catch (e) { debug('brew was found, but nss is not installed'); if (installCertutil) { debug('attempting to install nss via brew'); run('brew install nss'); - return path.join(run('brew --prefix nss').toString(), 'bin', 'certutil'); + certutilPath = path.join(run('brew --prefix nss').toString().trim(), 'bin', 'certutil'); + } else { + return false; } } + debug(`Found nss installed at ${ certutilPath }`); + return certutilPath; } } else if (isLinux) { debug('on linux, checking is nss is already installed'); @@ -255,7 +258,7 @@ function lookupOrInstallCertutil(installCertutil: boolean): boolean | string { } } debug('looks like nss is installed'); - return run('which certutil').toString(); + return run('which certutil').toString().trim(); } return false; }