'use strict';

require('../../../universalify/index.js');
require('../fs/index.js');
var Path = require('path');
var index$3 = require('../mkdirs/index.js');
var index = require('../path-exists/index.js');
var index$1 = require('../../../../_virtual/index21.js');
var index$2 = require('../../../../_virtual/index20.js');

const u = index$1.__exports.fromPromise;
const fs = index$2.__exports;
const path = Path;
const mkdir = index$3.mkdirs;
const pathExists = index.pathExists_1.pathExists;

async function outputFile (file, data, encoding = 'utf-8') {
  const dir = path.dirname(file);

  if (!(await pathExists(dir))) {
    await mkdir.mkdirs(dir);
  }

  return fs.writeFile(file, data, encoding)
}

function outputFileSync (file, ...args) {
  const dir = path.dirname(file);
  if (!fs.existsSync(dir)) {
    mkdir.mkdirsSync(dir);
  }

  fs.writeFileSync(file, ...args);
}

var outputFile_1 = {
  outputFile: u(outputFile),
  outputFileSync
};

exports.outputFile_1 = outputFile_1;
