All files / init init-standard-fix.js

91.67% Statements 11/12
50% Branches 2/4
100% Functions 5/5
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27          1x   1x 1x 1x         1x 1x 1x         1x 1x 1x      
import debug from 'debug';
import { spawn as yarnOrNPMSpawn } from 'yarn-or-npm';
 
import asyncOra from '../util/ora-handler';
 
const d = debug('electron-forge:init:standard-fix');
 
const run = dir =>
  new Promise((resolve, reject) => {
    const child = yarnOrNPMSpawn(['run', 'lint', '--', '--fix'], {
      stdio: 'inherit',
      cwd: dir,
    });
 
    child.on('exit', (code) => {
      Eif (code === 0) resolve();
      Iif (code !== 0) reject(new Error(`Failed to fix JS to standard style (${code})`));
    });
  });
 
export default async (dir) => {
  await asyncOra('Applying Standard Style to JS', async () => {
    d('executing "standard --fix" in:', dir);
    await run(dir);
  });
};