-
Notifications
You must be signed in to change notification settings - Fork 327
/
Copy pathlint.mjs
49 lines (40 loc) · 1.24 KB
/
lint.mjs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
import { $, chalk } from 'zx';
$.env = {
...process.env,
FORCE_COLOR: 1,
};
$.stdio = 'inherit';
$.verbose = !!process.env.VERBOSE;
const [github, integration, scripts] = await Promise.allSettled([
$`echo "SKIPPING: pnpm eslint .github/workflows"`,
$`pnpm eslint integration`,
$`pnpm eslint scripts`,
]);
let packages;
try {
await $`pnpm turbo lint`;
} catch (error) {
packages = error;
}
function logLintResult(status, directory, command) {
console.log('');
if (status === 'rejected') {
console.log(chalk.red(`${directory} lint failed`));
console.log(`Run '${chalk.bold(command)}' to reproduce the error`);
}
if (status === 'fulfilled') {
console.log(chalk.green(`${directory} lint passed`));
}
}
logLintResult(github.status, 'GitHub Actions', 'pnpm eslint .github/workflows');
logLintResult(integration.status, 'Integration directory', 'pnpm eslint integration');
logLintResult(scripts.status, 'Scripts directory', 'pnpm eslint scripts');
if (packages?.exitCode) {
console.log('');
console.log(chalk.red('Packages lint failed'));
console.log(`Run '${chalk.bold('pnpm turbo lint')}' to reproduce the error`);
}
if (integration.status === 'rejected' || packages?.exitCode) {
process.exit(1);
}