-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 783 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (24 loc) · 783 Bytes
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
import { Tokenizer } from './src/tokenizer/tokenizer.js';
import fs from 'fs';
import { execSync } from 'child_process';
import { Parser } from './src/parser/parser.js';
import { Linter } from './src/linter/linter.js';
const fileName =
process.argv[2] && process.argv[2] !== '--fullLog'
? process.argv[2]
: 'test.js';
const file = fs.readFileSync(`./${fileName}`, 'utf8');
try {
execSync(`node --check ${fileName}`, { encoding: 'utf8', stdio: 'pipe' });
} catch (e) {
console.log(
'Before executing the linter please fix syntax errors:\n' + e.stderr
);
process.exit();
}
const tokenizer = new Tokenizer(file);
tokenizer.tokenize();
const parser = new Parser(tokenizer);
parser.parse();
const linter = new Linter(parser.parts, fileName);
linter.lint();