All files ensure-output.js

0% Statements 0/6
0% Branches 0/4
0% Functions 0/2
0% Lines 0/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
import fs from 'fs-promise';
import path from 'path';
 
// 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 fs.remove(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 fs.remove(file);
  }
  await fs.mkdirs(path.dirname(file));
}
 
export { ensureDirectory, ensureFile };