Last active
November 15, 2018 18:38
-
-
Save npearce/e33ad0633163f46802053b6076320112 to your computer and use it in GitHub Desktop.
Create gzipped tarballs in nodejs with correct owners & permissions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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