Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
594 bytes
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | const path = require('path')
|
---|
4 | const fs = require('graceful-fs')
|
---|
5 | const rimraf = require('rimraf')
|
---|
6 | const log = require('./logger').create('temp-dir')
|
---|
7 |
|
---|
8 | const TEMP_DIR = require('os').tmpdir()
|
---|
9 |
|
---|
10 | module.exports = {
|
---|
11 | getPath (suffix) {
|
---|
12 | return path.normalize(TEMP_DIR + suffix)
|
---|
13 | },
|
---|
14 |
|
---|
15 | create (path) {
|
---|
16 | log.debug(`Creating temp dir at ${path}`)
|
---|
17 |
|
---|
18 | try {
|
---|
19 | fs.mkdirSync(path)
|
---|
20 | } catch (e) {
|
---|
21 | log.warn(`Failed to create a temp dir at ${path}`)
|
---|
22 | }
|
---|
23 |
|
---|
24 | return path
|
---|
25 | },
|
---|
26 |
|
---|
27 | remove (path, done) {
|
---|
28 | log.debug(`Cleaning temp dir ${path}`)
|
---|
29 | rimraf(path, done)
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.