"use strict";

const {
  spawn
} = require('child_process');

const eslintPackages = ['eslint@7.18.0', 'eslint-config-airbnb@18.2.1', 'eslint-plugin-import@2.22.1', 'eslint-plugin-jsx-a11y@6.4.1', 'eslint-plugin-react@7.22.0', 'eslint-plugin-css-modules@2.11.0', '@zohodesk/eslint-plugin-react-performance@1.0.3', '@zohodesk/eslint-plugin-zsecurity@0.0.1-beta.4', 'eslint-plugin-react-hooks@4.2.0'];
const prettierPackages = ['prettier@2.2.1'];
const eslintPrettierConfig = ['eslint-config-prettier@7.2.0']; // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;

function runInstall(packages) {
  return spawn('npm', ['i', ...packages, '--save-dev'], {
    detached: true,
    stdio: 'inherit'
  });
}

function installLintStaged() {
  spawn('npx', ['mrm', 'lint-staged'], {
    detached: true,
    stdio: 'inherit'
  });
}

module.exports = {
  eslintPackages,
  prettierPackages,
  eslintPrettierConfig,
  installLintStaged,
  runInstall
};