forked from exercism/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint
More file actions
executable file
·41 lines (32 loc) · 1.04 KB
/
lint
File metadata and controls
executable file
·41 lines (32 loc) · 1.04 KB
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
#!/usr/bin/env node
/**
* Run this script (from root directory): npx babel-node scripts/lint
*
* This runs `eslint` on all sample solutions (and test) files
*/
const shell = require("shelljs");
const {
registerExitHandler,
prepareAndRun,
assignments: exercises,
shouldPrepare,
} = require("./helpers");
registerExitHandler();
const assignment = exercises.length === 0 ? exercises[0] : undefined;
// Prepare exercises and cleanup afterwards
shell.env["PREPARE"] =
shell.env["PREPARE"] === undefined || shell.env["PREPARE"];
shell.env["CLEANUP"] =
shell.env["CLEANUP"] === undefined || shell.env["CLEANUP"];
const count = shouldPrepare() ? exercises.length : "all";
const infoStr = assignment
? `Running lint for ${assignment}...`
: `Running lint for ${count} exercises...`;
const failureStr = "[Failure] Lint check failed!";
// Run lint all at once
prepareAndRun("npx eslint tmp_exercises", infoStr, failureStr);
shell.echo(
assignment
? `[Success] Lint passed for ${assignment}`
: `[Success] Lint passed for ${count} exercises`
);