Skip to content

Instantly share code, notes, and snippets.

@lucasreppewelander
Created March 8, 2018 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasreppewelander/9c87115b28cbd5d556e22b500deb555c to your computer and use it in GitHub Desktop.
Save lucasreppewelander/9c87115b28cbd5d556e22b500deb555c to your computer and use it in GitHub Desktop.
Async await
const mkdirp = require('mkdirp');
const fs = require('fs');
// async here is critical
const writeFile = async (path, content) => {
// await makes everything wait for that function to execute
await mkdirp(path);
// here you could do whatever you want
await fs.writeFileSync(path, content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment