Skip to content

Instantly share code, notes, and snippets.

@npearce
Last active November 15, 2018 18:38
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 npearce/e33ad0633163f46802053b6076320112 to your computer and use it in GitHub Desktop.
Save npearce/e33ad0633163f46802053b6076320112 to your computer and use it in GitHub Desktop.
Create gzipped tarballs in nodejs with correct owners & permissions.
//NOTE: the source permissions need to be set appropriately, also.
// npm i --save targz
const targz = require('targz')
targz.compress({
src: '/tmp/mydirectory',
dest: 'output/filename.tgz',
tar: {
dmode: 0775, // Directories: rwxrwxr-x
fmode: 0664, // Files: rw-rw-r--
umask: 0002, // Sets umask (default perm) for newly created files
map: function(header) {
header.name = './'+header.name // Add './' prefix
header.uname = 'user'
header.gname = 'group'
return header
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment