Skip to content
Permalink
Browse files

refactor(generic): add debug calls to the linter

  • Loading branch information
MarshallOfSound committed Dec 4, 2016
1 parent 2344995 commit 3e11610923848a37ff9b0e184a0d346846b9506e
Showing with 11 additions and 5 deletions.
  1. +10 −4 src/electron-forge-lint.js
  2. +1 −1 src/util/resolve-dir.js
@@ -1,4 +1,5 @@
import 'colors';
import debug from 'debug';
import fs from 'fs-promise';
import path from 'path';
import program from 'commander';
@@ -8,8 +9,10 @@ import { spawn as yarnOrNPMSpawn } from 'yarn-or-npm';
import './util/terminate';
import resolveDir from './util/resolve-dir';

const d = debug('electron-forge:lint');

const main = async () => {
const lintSpinner = ora('Linting Application').start();
const lintSpinner = ora.ora('Linting Application').start();
let dir = process.cwd();
program
.version(require('../package.json').version)
@@ -32,17 +35,20 @@ const main = async () => {
process.exit(1);
}

d('executing "run lint -- --color" in dir:', dir);
const child = yarnOrNPMSpawn(['run', 'lint', '--', '--color'], {
cwd: dir,
});
const output = [];
child.stdout.on('data', data => output.push(data.toString()));
child.stderr.on('data', data => output.push(data.toString().red));
child.on('exit', (code) => {
if (code !== 0) lintSpinner.fail();
if (code === 0) lintSpinner.succeed();
output.forEach(data => process.stdout.write(data));
if (code !== 0) process.exit(code);
if (code !== 0) {
lintSpinner.fail();
output.forEach(data => process.stdout.write(data));
process.exit(code);
}
});
};

@@ -10,7 +10,7 @@ export default async (dir) => {
while (prevDir !== mDir) {
prevDir = mDir;
const testPath = path.resolve(mDir, 'package.json');
d('searching for project in', testPath);
d('searching for project in:', mDir);
if (await fs.exists(testPath)) {
const packageJSON = JSON.parse(await fs.readFile(testPath, 'utf8'));

0 comments on commit 3e11610

Please sign in to comment.
You can’t perform that action at this time.