Skip to content

Commit

Permalink
Use ensureDir
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesboeufs committed Sep 6, 2020
1 parent 0cd043b commit 5d517ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
const {promisify} = require('util')
const {dirname} = require('path')
const fs = require('fs')
const {remove} = require('fs-extra')
const {ensureDir, remove} = require('fs-extra')

const mkdirp = promisify(require('mkdirp'))
const glob = promisify(require('glob'))

const readdir = promisify(fs.readdir)
Expand All @@ -17,12 +16,12 @@ const cache = new Set()

async function ensureDirectoryExists(path) {
if (cache.has(path)) return
await mkdirp(path)
await ensureDir(path)
}

async function recreateDirectory(path) {
await remove(path)
await mkdirp(path)
await ensureDir(path)
}

async function createFile(path, data) {
Expand All @@ -32,7 +31,6 @@ async function createFile(path, data) {
}

module.exports = {
mkdirp,
glob,
readdir,
rename,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"glob": "^7.1.6",
"lodash": "^4.17.20",
"mapshaper": "^0.4.123",
"mkdirp": "^0.5.1",
"moment": "^2.27.0",
"pumpify": "^2.0.1",
"worker-farm": "^1.7.0",
Expand Down

0 comments on commit 5d517ac

Please sign in to comment.