Skip to content

Commit

Permalink
Add export default
Browse files Browse the repository at this point in the history
  • Loading branch information
grant0417 committed May 30, 2024
1 parent c1a9145 commit 838f286
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/aws_cli_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def parseBasicCommand(command):

def saveJsonAsSpec(d, path):
prefix = (
"export const completionSpec: Fig.Spec ="
"export const completionSpec: Fig.Spec = "
if exportTypescript
else "var completionSpec ="
else "var completionSpec = "
)
extension = ".ts" if exportTypescript else ".js"

Expand All @@ -165,7 +165,13 @@ def saveJsonAsSpec(d, path):
)
file_path.parent.mkdir(parents=True, exist_ok=True)

final = f"{prefix} {json.dumps(d, indent=4)}"
suffix = (
";\n\nexport default completionSpec;"
if exportTypescript
else ";\n\nmodule.exports = completionSpec;"
)

final = f"{prefix}{json.dumps(d, indent=4)}{suffix}"
file_path.write_text(final)


Expand Down

0 comments on commit 838f286

Please sign in to comment.