-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git.clone()
returns SyntaxError: await is only valid in async function
#51
Comments
This is javascript ES6 error, the proper syntax looks like this: async function foo() {
await git.clone({
fs,
dir,
url: 'https://github.com/isomorphic-git/isomorphic-git',
ref: 'master',
singleBranch: true,
depth: 10
});
} top level await is only available in console developer tools and I think that was proposal to add this to the language but I don't know the status. if you want top level you need to create async IIFE: async (() => {
await git.clone({
fs,
dir,
url: 'https://github.com/isomorphic-git/isomorphic-git',
ref: 'master',
singleBranch: true,
depth: 10
});
})(); |
@wmhilton This can be added to docs, not every one will know everything about ES6. I had this problem with jQuery Terminal when the user didn't know that he need to escape \ in string when he create ASCII art. I've added that do getting started guide next to the relevant part about greetings where you put welcome message. |
git.cone()
returns SyntaxError: await is only valid in async functiongit.clone()
returns SyntaxError: await is only valid in async function
Now that we're at it. Is there a way for git.clone to have a callback? |
@millette I know about the proposal it was comment about current implementations. AFAIK browsers don't allow top level await yet, not sure about babel. |
Just trying to be helpful by providing the reference. https://v8.dev/features/top-level-await#support links to current browser issues. |
Please be sure to mention:
Node
<script>
tag what CDN URL)Following the node quickstart tutorial, the below code returns
SyntaxError: await is only valid in async function
:It seems per the tutorial and here that we should be able to use await, since
.clone()
returns a promise.The text was updated successfully, but these errors were encountered: