Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(extract): always extract as current user gid/uid
Browse files Browse the repository at this point in the history
BREAKING CHANGE: pacote will no longer set ownership of extracted
contents -- uid/gid will *only* be used for the cache and other internal
details.
  • Loading branch information
zkat committed Jun 29, 2017
1 parent 992a14e commit 6fc01a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 69 deletions.
13 changes: 9 additions & 4 deletions lib/extract-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ const path = require('path')
const pipeline = require('mississippi').pipeline
const tar = require('tar-fs')

let uid
let gid
if (process.platform !== 'win32') {
uid = process.getuid()
gid = process.getgid()
}

module.exports = extractStream
function extractStream (dest, opts) {
opts = opts || {}
const sawIgnores = {}
return pipeline(gunzip(), tar.extract(dest, {
map: (header) => {
if (process.platform !== 'win32') {
header.uid = opts.uid == null ? header.uid : opts.uid
header.gid = opts.gid == null ? header.gid : opts.gid
}
if (uid != null) { header.uid = uid }
if (gid != null) { header.gid = gid }
// Note: This mirrors logic in the fs read operations that are
// employed during tarball creation, in the fstream-npm module.
// It is duplicated here to handle tarballs that are created
Expand Down
65 changes: 0 additions & 65 deletions test/extract-stream.chown.js

This file was deleted.

0 comments on commit 6fc01a5

Please sign in to comment.