From b152483f26914cee5a6bc6e9dd08a97364adb7c4 Mon Sep 17 00:00:00 2001 From: Dane Pilcher Date: Wed, 25 Oct 2023 11:12:01 -0600 Subject: [PATCH] ci: use full path to amplify cli --- packages/amplify-codegen-e2e-core/src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/amplify-codegen-e2e-core/src/index.ts b/packages/amplify-codegen-e2e-core/src/index.ts index 32159adf8..a292d9933 100644 --- a/packages/amplify-codegen-e2e-core/src/index.ts +++ b/packages/amplify-codegen-e2e-core/src/index.ts @@ -24,14 +24,18 @@ declare global { const amplifyTestsDir = 'amplify-codegen-e2e-tests'; export function getCLIPath(testingWithLatestCodebase = false) { + let commandName = 'amplify-dev'; if (isCI() && !testingWithLatestCodebase) { - return 'amplify'; + commandName = 'amplify'; } - return 'amplify-dev'; + + return execSync(`which ${commandName}`) + .toString() + .trim(); } export function isCI(): boolean { - return process.env.CI && (process.env.CODEBUILD) ? true : false; + return process.env.CI && process.env.CODEBUILD ? true : false; } export function injectSessionToken(profileName: string) { @@ -57,7 +61,9 @@ export async function createNewProjectDir( projectName: string, prefix = path.join(fs.realpathSync(os.tmpdir()), amplifyTestsDir), ): Promise { - const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim(); + const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }) + .toString() + .trim(); let projectDir; do { const randomId = await global.getRandomId();