Skip to content

Commit

Permalink
refactor(temp-dir): update lib/temp_dir.js to ES6 (#3049)
Browse files Browse the repository at this point in the history
  • Loading branch information
lusarz authored and johnjbarton committed Jun 16, 2018
1 parent f8f3ebc commit ab3c0e3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/temp_dir.js
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)
}
}

0 comments on commit ab3c0e3

Please sign in to comment.