refactor(generic): add debug calls to the linter
This commit is contained in:
Родитель
23449956f0
Коммит
3e11610923
|
@ -1,4 +1,5 @@
|
||||||
import 'colors';
|
import 'colors';
|
||||||
|
import debug from 'debug';
|
||||||
import fs from 'fs-promise';
|
import fs from 'fs-promise';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import program from 'commander';
|
import program from 'commander';
|
||||||
|
@ -8,8 +9,10 @@ import { spawn as yarnOrNPMSpawn } from 'yarn-or-npm';
|
||||||
import './util/terminate';
|
import './util/terminate';
|
||||||
import resolveDir from './util/resolve-dir';
|
import resolveDir from './util/resolve-dir';
|
||||||
|
|
||||||
|
const d = debug('electron-forge:lint');
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const lintSpinner = ora('Linting Application').start();
|
const lintSpinner = ora.ora('Linting Application').start();
|
||||||
let dir = process.cwd();
|
let dir = process.cwd();
|
||||||
program
|
program
|
||||||
.version(require('../package.json').version)
|
.version(require('../package.json').version)
|
||||||
|
@ -32,6 +35,7 @@ const main = async () => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d('executing "run lint -- --color" in dir:', dir);
|
||||||
const child = yarnOrNPMSpawn(['run', 'lint', '--', '--color'], {
|
const child = yarnOrNPMSpawn(['run', 'lint', '--', '--color'], {
|
||||||
cwd: dir,
|
cwd: dir,
|
||||||
});
|
});
|
||||||
|
@ -39,10 +43,12 @@ const main = async () => {
|
||||||
child.stdout.on('data', data => output.push(data.toString()));
|
child.stdout.on('data', data => output.push(data.toString()));
|
||||||
child.stderr.on('data', data => output.push(data.toString().red));
|
child.stderr.on('data', data => output.push(data.toString().red));
|
||||||
child.on('exit', (code) => {
|
child.on('exit', (code) => {
|
||||||
if (code !== 0) lintSpinner.fail();
|
|
||||||
if (code === 0) lintSpinner.succeed();
|
if (code === 0) lintSpinner.succeed();
|
||||||
output.forEach(data => process.stdout.write(data));
|
if (code !== 0) {
|
||||||
if (code !== 0) process.exit(code);
|
lintSpinner.fail();
|
||||||
|
output.forEach(data => process.stdout.write(data));
|
||||||
|
process.exit(code);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default async (dir) => {
|
||||||
while (prevDir !== mDir) {
|
while (prevDir !== mDir) {
|
||||||
prevDir = mDir;
|
prevDir = mDir;
|
||||||
const testPath = path.resolve(mDir, 'package.json');
|
const testPath = path.resolve(mDir, 'package.json');
|
||||||
d('searching for project in', testPath);
|
d('searching for project in:', mDir);
|
||||||
if (await fs.exists(testPath)) {
|
if (await fs.exists(testPath)) {
|
||||||
const packageJSON = JSON.parse(await fs.readFile(testPath, 'utf8'));
|
const packageJSON = JSON.parse(await fs.readFile(testPath, 'utf8'));
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче