-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(temp-dir): update lib/temp_dir.js to ES6 (#3049)
- Loading branch information
1 parent
f8f3ebc
commit ab3c0e3
Showing
1 changed file
with
13 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
var path = require('path') | ||
var fs = require('graceful-fs') | ||
var os = require('os') | ||
var rimraf = require('rimraf') | ||
var log = require('./logger').create('temp-dir') | ||
'use strict' | ||
|
||
var TEMP_DIR = os.tmpdir() | ||
const path = require('path') | ||
const fs = require('graceful-fs') | ||
const rimraf = require('rimraf') | ||
const log = require('./logger').create('temp-dir') | ||
|
||
const TEMP_DIR = require('os').tmpdir() | ||
|
||
module.exports = { | ||
getPath: function (suffix) { | ||
getPath (suffix) { | ||
return path.normalize(TEMP_DIR + suffix) | ||
}, | ||
|
||
create: function (path) { | ||
log.debug('Creating temp dir at %s', path) | ||
create (path) { | ||
log.debug(`Creating temp dir at ${path}`) | ||
|
||
try { | ||
fs.mkdirSync(path) | ||
} catch (e) { | ||
log.warn('Failed to create a temp dir at %s', path) | ||
log.warn(`Failed to create a temp dir at ${path}`) | ||
} | ||
|
||
return path | ||
}, | ||
|
||
remove: function (path, done) { | ||
log.debug('Cleaning temp dir %s', path) | ||
remove (path, done) { | ||
log.debug(`Cleaning temp dir ${path}`) | ||
rimraf(path, done) | ||
} | ||
} |