Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created July 28, 2021 17:17
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 isaacs/0a05e95b930cc3962fa727e3c02d7161 to your computer and use it in GitHub Desktop.
Save isaacs/0a05e95b930cc3962fa727e3c02d7161 to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p gh-274/folder1
touch gh-274/folder1/main.js
touch gh-274/index.js
tree gh-274/
node - <<JS
const tar = require('./')
tar.c({
sync: true,
gzip: true,
file: 'gh-274.tar.gz',
cwd: 'gh-274',
}, require('fs').readdirSync('gh-274'))
JS
tar tvf gh-274.tar.gz
:<<OUTPUT
gh-274/
├── folder1
│   └── main.js
└── index.js
1 directory, 2 files
drwxr-xr-x 0 isaacs 20 0 Jul 28 10:15 folder1/
-rw-r--r-- 0 isaacs 20 0 Jul 28 10:17 folder1/main.js
-rw-r--r-- 0 isaacs 20 0 Jul 28 10:17 index.js
OUTPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment