source: trip-planner-front/node_modules/cacache/lib/util/tmp.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 800 bytes
Line 
1'use strict'
2
3const util = require('util')
4
5const fixOwner = require('./fix-owner')
6const path = require('path')
7const rimraf = util.promisify(require('rimraf'))
8const uniqueFilename = require('unique-filename')
9const { disposer } = require('./disposer')
10
11module.exports.mkdir = mktmpdir
12
13function mktmpdir (cache, opts = {}) {
14 const { tmpPrefix } = opts
15 const tmpTarget = uniqueFilename(path.join(cache, 'tmp'), tmpPrefix)
16 return fixOwner.mkdirfix(cache, tmpTarget).then(() => {
17 return tmpTarget
18 })
19}
20
21module.exports.withTmp = withTmp
22
23function withTmp (cache, opts, cb) {
24 if (!cb) {
25 cb = opts
26 opts = {}
27 }
28 return disposer(mktmpdir(cache, opts), rimraf, cb)
29}
30
31module.exports.fix = fixtmpdir
32
33function fixtmpdir (cache) {
34 return fixOwner(cache, path.join(cache, 'tmp'))
35}
Note: See TracBrowser for help on using the repository browser.