Skip to content

Commit

Permalink
fix #14 [...command.split(' ')]
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Ludwig committed Mar 3, 2021
1 parent 0c3fe06 commit 29bf364
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 47 deletions.
5 changes: 4 additions & 1 deletion lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 6 additions & 22 deletions lib/index.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.spec.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 27 additions & 21 deletions src/index.spec.ts
Expand Up @@ -22,7 +22,13 @@ describe('iam list-users', () => {

const aws = new Aws(options);

return aws.command('iam list-users').then((data: any) => {
//const command = 'iam list-users --region us-west-1';
const command = `iam \
list-users \
--region us-west-1`;


return aws.command(command).then((data: any) => {
//console.log('data = ', util.inspect(data, { depth: 10 }));
expect(data).toBeTruthy();
expect(data.object.Users).toBeTruthy();
Expand All @@ -33,30 +39,30 @@ describe('iam list-users', () => {
});


describe('iam list-users', () => {
it('should fail with invalid sessionToken', () => {
const result = true;
// describe('iam list-users', () => {
// it('should fail with invalid sessionToken', () => {
// const result = true;

expect(result).toBeTruthy();
const options = new Options(
/* accessKey */ config.accessKeyId,
/* secretKey */ config.secretAccessKey,
/* sessionToken */ 'invalid',
/* currentWorkingDirectory */ undefined,
);
// expect(result).toBeTruthy();
// const options = new Options(
// /* accessKey */ config.accessKeyId,
// /* secretKey */ config.secretAccessKey,
// /* sessionToken */ 'invalid',
// /* currentWorkingDirectory */ undefined,
// );


const aws = new Aws(options);
// const aws = new Aws(options);

let flag = false;
return aws.command('iam list-users').then((data: any) => {
flag = true;
}).catch((r) => {
expect(flag).toBeFalsy();
//console.log('r = ', r);
});
// let flag = false;
// return aws.command('iam list-users').then((data: any) => {
// flag = true;
// }).catch((r) => {
// expect(flag).toBeFalsy();
// //console.log('r = ', r);
// });


});
});
// });
// });

6 changes: 5 additions & 1 deletion src/index.ts
Expand Up @@ -61,8 +61,12 @@ export class Aws {

//console.log('exec options =', execOptions);
//console.log('options.cliPath =', this.options.cliPath);
let cmd = [...command.split(' ')];
cmd = cmd.filter(v => v.length > 0);
//console.log('cmd2 = ', cmd);

return new Promise<{ stderr: string, stdout: string }>( (resolve, reject) => {
execFile(this.options.cliPath, [...command.split(' ')], execOptions, (error: Error | null, stdout: string, stderr: string) => {
execFile(this.options.cliPath, cmd, execOptions, (error: Error | null, stdout: string, stderr: string) => {
if (error) {
const message = `error: '${error}' stdout = '${stdout}' stderr = '${stderr}'`;
//console.error(message);
Expand Down

0 comments on commit 29bf364

Please sign in to comment.