Skip to content

Commit 8a8e33d

Browse files
authored
fix(c9): use 'fs' for c9 when calling writeFile (#4416)
Problem: the C9 stub for the vscode api's writeFile does not support writing outside of the workspace dir, which can happen when adding new IAM credentials. Solution: Fall back to a standard fs library for C9. #### Testing Tested on C9 <!--- REMINDER: - Read CONTRIBUTING.md first. - Add test coverage for your changes. - Update the changelog using `npm run newChange`. - Link to related issues/commits. - Testing: how did you test your changes? - Screenshots --> ## License By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Co-authored-by: aws-toolkit-automation <>
1 parent a4c9e05 commit 8a8e33d

File tree

1 file changed

+7
-0
lines changed
  • packages/toolkit/src/srcShared

1 file changed

+7
-0
lines changed

packages/toolkit/src/srcShared/fs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ export class FileSystemCommon {
105105
*/
106106
async writeFile(path: Uri | string, data: string | Uint8Array): Promise<void> {
107107
path = FileSystemCommon.getUri(path)
108+
109+
// vscode.workspace.writeFile is stubbed in C9 has limited functionality,
110+
// e.g. cannot write outside of open workspace
111+
if (isCloud9()) {
112+
await fsPromises.writeFile(path.fsPath, FileSystemCommon.asArray(data))
113+
return
114+
}
108115
return fs.writeFile(path, FileSystemCommon.asArray(data))
109116
}
110117

0 commit comments

Comments
 (0)