"use strict";

const fs = require('fs');

const {
  log
} = require('..');

async function copyConfigs(file) {
  // copy the file in react-cli to current working directory
  fs.readFile(require.resolve(`../../../files/${file}.js`), (err, data) => {
    if (err) log("[LINT SETUP] There's error in reading the config file", file);else {
      fs.writeFile(`.${file}.js`, data, writeError => {
        if (writeError) {
          log("[LINT SETUP] There's error in writing the config file: ", file, writeError);
        } else {
          log('[LINT SETUP] Added config file', file);
        }
      });
    }
  });
}

module.exports = copyConfigs;