Fix tests

This commit is contained in:
CrazyMax 2020-08-21 14:56:11 +02:00
parent 25aa6aa30c
commit 04f461cc60
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 30 additions and 20 deletions

View file

@ -10,15 +10,19 @@ export const getCLI = async (): Promise<string> => {
return io.which('aws', true);
};
export const getCLIVersion = async (): Promise<string | undefined> => {
return execm.exec('aws', ['--version'], true).then(res => {
export const getCLICmdOutput = async (args: string[]): Promise<string> => {
return execm.exec(await getCLI(), args, true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
return parseCLIVersion(res.stdout);
return res.stdout;
});
};
export const getCLIVersion = async (): Promise<string | undefined> => {
return parseCLIVersion(await getCLICmdOutput(['--version']));
};
export const parseCLIVersion = async (stdout: string): Promise<string | undefined> => {
const matches = /aws-cli\/([0-9.]+)/.exec(stdout);
if (matches) {