Skip to content

Instantly share code, notes, and snippets.

@jdiamond
Created September 11, 2020 03:12
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 jdiamond/aff2cbba4ea2c7a02189b0fc85235e1f to your computer and use it in GitHub Desktop.
Save jdiamond/aff2cbba4ea2c7a02189b0fc85235e1f to your computer and use it in GitHub Desktop.
top-level await
{
"type": "module"
}
#!/usr/bin/env node
import { exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
const { stdout } = await execAsync('ls -l');
console.log(stdout);
@jdiamond
Copy link
Author

Here is the output:

❯ node -v
v14.10.1

❯ ./test.js
total 16
-rw-r--r--  1 jason  staff   23 Sep 10 19:54 package.json
-rwxr-xr-x  1 jason  staff  197 Sep 10 19:56 test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment