Sha256: e58e026983a4b9a04b58c8620a2cc8d960578daae088d7acae7e3d069d14ab2f

Contents?: true

Size: 956 Bytes

Versions: 9

Compression:

Stored size: 956 Bytes

Contents

'use strict'

const BB = require('bluebird')

const figgyPudding = require('figgy-pudding')
const fixOwner = require('./fix-owner')
const path = require('path')
const rimraf = BB.promisify(require('rimraf'))
const uniqueFilename = require('unique-filename')

const TmpOpts = figgyPudding({
  tmpPrefix: {},
  uid: {},
  gid: {}
})

module.exports.mkdir = mktmpdir
function mktmpdir (cache, opts) {
  opts = TmpOpts(opts)
  const tmpTarget = uniqueFilename(path.join(cache, 'tmp'), opts.tmpPrefix)
  return fixOwner.mkdirfix(tmpTarget, opts.uid, opts.gid).then(() => {
    return tmpTarget
  })
}

module.exports.withTmp = withTmp
function withTmp (cache, opts, cb) {
  if (!cb) {
    cb = opts
    opts = null
  }
  opts = TmpOpts(opts)
  return BB.using(mktmpdir(cache, opts).disposer(rimraf), cb)
}

module.exports.fix = fixtmpdir
function fixtmpdir (cache, opts) {
  opts = TmpOpts(opts)
  return fixOwner(path.join(cache, 'tmp'), opts.uid, opts.gid)
}

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/cacache/lib/util/tmp.js
disco_app-0.18.2 test/dummy/node_modules/cacache/lib/util/tmp.js
jester-data-8.0.0 node_modules/cacache/lib/util/tmp.js
ezii-os-5.2.1 node_modules/cacache/lib/util/tmp.js
ezii-os-2.0.1 node_modules/cacache/lib/util/tmp.js
ezii-os-1.1.0 node_modules/cacache/lib/util/tmp.js
ezii-os-1.0.0 node_modules/cacache/lib/util/tmp.js
ezii-os-0.0.0.1.0 node_modules/cacache/lib/util/tmp.js
ezii-os-0.0.0.0.1 node_modules/cacache/lib/util/tmp.js