source: node_modules/cacache/lib/util/tmp.js@ 62b2964

finki-main main
Last change on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 839 bytes
RevLine 
[81bc7da]1'use strict'
2
3const fs = require('@npmcli/fs')
4
5const fixOwner = require('./fix-owner')
6const path = require('path')
7
8module.exports.mkdir = mktmpdir
9
10function mktmpdir (cache, opts = {}) {
11 const { tmpPrefix } = opts
12 const tmpDir = path.join(cache, 'tmp')
13 return fs.mkdir(tmpDir, { recursive: true, owner: 'inherit' })
14 .then(() => {
15 // do not use path.join(), it drops the trailing / if tmpPrefix is unset
16 const target = `${tmpDir}${path.sep}${tmpPrefix || ''}`
17 return fs.mkdtemp(target, { owner: 'inherit' })
18 })
19}
20
21module.exports.withTmp = withTmp
22
23function withTmp (cache, opts, cb) {
24 if (!cb) {
25 cb = opts
26 opts = {}
27 }
28 return fs.withTempDir(path.join(cache, 'tmp'), cb, opts)
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.