From 01f7e3b3fdab3022378cac86dc811dca4216e879 Mon Sep 17 00:00:00 2001 From: Jared Petersen Date: Sat, 2 May 2020 16:27:48 -0700 Subject: [PATCH] changed gpg import to run in key directory --- __tests__/auth.test.ts | 12 +++++++++--- dist/index.js | Bin 170074 -> 170043 bytes src/auth.ts | 5 ++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts index 09745a6b..4a56744e 100644 --- a/__tests__/auth.test.ts +++ b/__tests__/auth.test.ts @@ -23,7 +23,7 @@ const env = process.env; const m2Dir = path.join(__dirname, auth.M2_DIR); const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE); const gpgDir = path.join(__dirname, auth.GPG_DIR); -const gpgFile = path.join(gpgDir, auth.GPG_FILE); +const gpgFile = auth.GPG_FILE; describe('auth tests', () => { beforeEach(async () => { @@ -180,7 +180,11 @@ describe('auth tests', () => { await auth.configAuthentication(id, username, password, gpgPrivateKey); - expect(exec.exec).toHaveBeenCalledWith(`gpg --import --batch ${gpgFile}`); + expect(exec.exec).toHaveBeenCalledWith( + 'gpg', + ['--import', '--batch', gpgFile], + {cwd: gpgDir} + ); expect(fs.existsSync(gpgDir)).toBe(false); }, 100000); @@ -193,7 +197,9 @@ describe('auth tests', () => { await auth.configAuthentication(id, username, password); expect(exec.exec).not.toHaveBeenCalledWith( - `gpg --import --batch ${gpgFile}` + 'gpg', + ['--import', '--batch', gpgFile], + {cwd: gpgDir} ); expect(fs.existsSync(gpgDir)).toBe(false); diff --git a/dist/index.js b/dist/index.js index 22077061cac97faf1a200e178a19e09e14311f84..02a84d71bbf5ca62852b72d1d8ab0f150e7f4768 100644 GIT binary patch delta 109 zcmcb$fot~$u7)j)0Ws69Vi~!n_r@@?Pq&U?G~PZXhOvytDYYUsSr0^LsHYdCtLrF4 ztLy4!<`(1^l>j+Fc2Z(Vat4r@mYI_ptD{h@kX)W(rI3AfBR=L96i delta 97 zcmdnJf$P==u7)j)0Ws6#QW!a>*T*o5PEQ080Wpk%+o!}Zmhnt~Z^Fbj-71|?e>ztt yBbQP_dO^B^u5M;-L4HvQkdc&FlANKSQk|2ZoLG{XpI4jE?vu&5-6xajy&eEl*dYu6 diff --git a/src/auth.ts b/src/auth.ts index b343f614..46fbb67f 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -13,8 +13,8 @@ export const GPG_FILE = 'private.asc'; export const DEFAULT_ID = 'github'; export const DEFAULT_USERNAME = 'GITHUB_ACTOR'; export const DEFAULT_PASSWORD = 'GITHUB_TOKEN'; -export const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; export const DEFAULT_GPG_PRIVATE_KEY = ''; +export const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; export async function configAuthentication( id = DEFAULT_ID, @@ -110,6 +110,5 @@ async function write(directory: string, file: string, contents: string) { } async function importGpgKey(directory: string, file: string) { - const location = path.join(directory, file); - exec.exec(`gpg --import --batch ${location}`); + exec.exec('gpg', ['--import', '--batch', file], {cwd: directory}); }