Skip to content
This repository was archived by the owner on May 16, 2020. It is now read-only.

Commit 63af3ad

Browse files
fix(atlauncher-scripts): don't allow running lint watch in lerna root
1 parent b9022e1 commit 63af3ad

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/atlauncher-scripts/scripts/lint-js.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const chalk = require('chalk');
12
const utils = require('../utils');
23

34
const args = process.argv.slice(2);
@@ -17,6 +18,11 @@ if (args.length) {
1718
}
1819

1920
if (watch) {
21+
if (utils.wasRunInLernaRoot()) {
22+
console.log(chalk.white.bgRed('Cannot run watch within a lerna root'));
23+
process.exit(1);
24+
}
25+
2026
const processArguments = [utils.getProjectPath('src/**/*.js'), '--initial', '-c npm run lint:js'];
2127

2228
utils.spawnSyncProcess(utils.getNodeModulesBinPath('chokidar'), processArguments);
@@ -36,4 +42,4 @@ const processArguments = [
3642
debug && '--debug',
3743
].concat(utils.getProjectPaths('**/*.js'));
3844

39-
utils.spawnSyncProcess(utils.getNodeModulesBinPath('eslint'), processArgumentsS);
45+
utils.spawnSyncProcess(utils.getNodeModulesBinPath('eslint'), processArguments);

packages/atlauncher-scripts/utils/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ function getLernaPackagePaths() {
2121
return packages;
2222
}
2323

24+
/**
25+
* Determines if atlauncher-scripts was run from a lerna root.
26+
*
27+
* @returns {boolean}
28+
*/
29+
function wasRunInLernaRoot() {
30+
return getLernaPackagePaths().length;
31+
}
32+
2433
/**
2534
* This ensures that the given path always ends with a / (or not);
2635
*
@@ -275,6 +284,7 @@ module.exports = {
275284
getProjectPath,
276285
getProjectPaths,
277286
spawnSyncProcess,
287+
wasRunInLernaRoot,
278288
getNodeModulesPath,
279289
getNodeModulesBinPath,
280290
getConfigFromPackageJson,

0 commit comments

Comments
 (0)