UNPKG

@aak.lear/eslint-config

Version:

This package simplifies the initial setup of eslint and prettier. It installs and apply eslint-config-airbnb to your project, also resolves peerDependencies that are required for eslint-config-airbnb package.

60 lines (49 loc) 1.38 kB
import spawn from 'cross-spawn'; export const installWithPeerDeps = async (packageNames) => { console.log('Installing packages\n'); await new Promise((resolve, reject) => { const command = 'npm'; const args = ['i', 'install-peerdeps', '-D']; const child = spawn(command, args, { stdio: 'inherit' }); child.on('close', (code) => { if (code === 0) { resolve(); } else { reject({ command: `${command} ${args.join(' ')}`, }); } }); }); for (const packageName of packageNames) { console.log(); await new Promise((resolve, reject) => { const command = 'install-peerdeps'; const args = ['-D', `${packageName}@latest`]; const child = spawn(command, args, { stdio: 'inherit' }); child.on('close', (code) => { if (code === 0) { resolve(); } else { reject({ command: `${command} ${args.join(' ')}`, }); } }); }); } await new Promise((resolve, reject) => { const command = 'npm'; const args = ['remove', 'install-peerdeps']; const child = spawn(command, args, { stdio: 'inherit' }); child.on('close', (code) => { if (code === 0) { resolve(); } else { reject({ command: `${command} ${args.join(' ')}`, }); } }); }); };