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();