-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(generic): replace mkdirp/rimraf calls with equivalent fs-pro…
…mise calls
- Loading branch information
Showing
8 changed files
with
18 additions
and
29 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
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
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
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
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
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,21 +1,22 @@ | ||
import fs from 'fs-promise'; | ||
import mkdirp from 'mkdirp'; | ||
import path from 'path'; | ||
import pify from 'pify'; | ||
import rimraf from 'rimraf'; | ||
|
||
// This is different from fs-extra's ensureDir because it wipes out the existing directory, | ||
// if it's found. | ||
async function ensureDirectory(dir) { | ||
if (await fs.exists(dir)) { | ||
await pify(rimraf)(dir); | ||
await fs.remove(dir); | ||
} | ||
return pify(mkdirp)(dir); | ||
return fs.mkdirs(dir); | ||
} | ||
|
||
// This is different from fs-extra's ensureFile because it wipes out the existing file, | ||
// if it's found. | ||
async function ensureFile(file) { | ||
if (await fs.exists(file)) { | ||
await pify(rimraf)(file); | ||
await fs.remove(file); | ||
} | ||
await pify(mkdirp)(path.dirname(file)); | ||
await fs.mkdirs(path.dirname(file)); | ||
} | ||
|
||
export { ensureDirectory, ensureFile }; |
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
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