Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
800 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | const util = require('util')
|
---|
| 4 |
|
---|
| 5 | const fixOwner = require('./fix-owner')
|
---|
| 6 | const path = require('path')
|
---|
| 7 | const rimraf = util.promisify(require('rimraf'))
|
---|
| 8 | const uniqueFilename = require('unique-filename')
|
---|
| 9 | const { disposer } = require('./disposer')
|
---|
| 10 |
|
---|
| 11 | module.exports.mkdir = mktmpdir
|
---|
| 12 |
|
---|
| 13 | function 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 |
|
---|
| 21 | module.exports.withTmp = withTmp
|
---|
| 22 |
|
---|
| 23 | function withTmp (cache, opts, cb) {
|
---|
| 24 | if (!cb) {
|
---|
| 25 | cb = opts
|
---|
| 26 | opts = {}
|
---|
| 27 | }
|
---|
| 28 | return disposer(mktmpdir(cache, opts), rimraf, cb)
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | module.exports.fix = fixtmpdir
|
---|
| 32 |
|
---|
| 33 | function fixtmpdir (cache) {
|
---|
| 34 | return fixOwner(cache, path.join(cache, 'tmp'))
|
---|
| 35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.