Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 28, 2019
1 parent 4db1465 commit 4d276e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/tap/publish-invalid-semver-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ var DEFAULT_PKG = {
'version': '1.2.3'
}

const isRoot = process.getuid && process.getuid() === 0
const sudoUID = isRoot ? +process.env.SUDO_UID : null
const sudoGID = isRoot ? +process.env.SUDO_GID : null
const { chownSync } = require('fs')
function resetPackage (options) {
CACHE_DIR = path.resolve(common.cache, '' + cacheIteration++)
mkdirp.sync(CACHE_DIR)
npm.config.set('cache', CACHE_DIR)

if (isRoot && sudoUID && sudoGID) {
chownSync(CACHE_DIR, sudoUID, sudoGID)
}

fs.writeFileSync(path.resolve(PKG_DIR, 'package.json'), DEFAULT_PKG)
}

Expand Down
8 changes: 8 additions & 0 deletions test/tap/update-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ function extend (a, b) {

const path = require('path')
let cacheIteration = 0
const isRoot = process.getuid && process.getuid() === 0
const sudoUID = isRoot ? +process.env.SUDO_UID : null
const sudoGID = isRoot ? +process.env.SUDO_GID : null
const { chownSync } = require('fs')
function resetPackage (options) {
CACHE_DIR = path.resolve(common.cache, '' + cacheIteration++)
npm.config.set('cache', CACHE_DIR)
mkdirp.sync(CACHE_DIR)

if (isRoot && sudoUID && sudoGID) {
chownSync(CACHE_DIR, sudoUID, sudoGID)
}

installAskedFor = undefined

mockParentJson = clone(DEFAULT_PKG)
Expand Down

0 comments on commit 4d276e2

Please sign in to comment.