Skip to content

Commit

Permalink
fix(toolkit): "ini.split is not a function" error when reading aws co…
Browse files Browse the repository at this point in the history
…nfig

Since `readFile` returns a `Buffer` and `ini.parse` expects 
a string, we need `toString()`.

Fixes #563
  • Loading branch information
Elad Ben-Israel committed Aug 14, 2018
1 parent 0cbb247 commit f5d94fe
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/aws-cdk/lib/api/util/sdk_ini_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ export class SharedIniFile {
}

private async ensureFileLoaded() {
if (!this.parsedContents) {
this.parsedContents = await fs.pathExists(this.filename)
? (AWS as any).util.ini.parse(await fs.readFile(this.filename))
: {};
if (this.parsedContents) {
return;
}

if (!await fs.pathExists(this.filename)) {
this.parsedContents = {};
return;
}

const contents: string = (await fs.readFile(this.filename)).toString();
this.parsedContents = (AWS as any).util.ini.parse(contents);
}
}

0 comments on commit f5d94fe

Please sign in to comment.