Skip to content
This repository was archived by the owner on Dec 4, 2021. It is now read-only.

Commit dfd0ca2

Browse files
Caleb HooverCaleb Hoover
Caleb Hoover
authored and
Caleb Hoover
committed
changes
1 parent 93343af commit dfd0ca2

File tree

7 files changed

+449
-98
lines changed

7 files changed

+449
-98
lines changed

bin/check

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ var yargs = require('yargs')
77
.describe('o', 'Output flag. Will output ast into ASTOutput.js.')
88
.showHelpOnFail(false);
99

10-
var check = require('../check.js'),
11-
colors = require('colors'),
10+
var check = require('../check.js'),
11+
colors = require('colors'),
1212
fs = require('fs'),
1313
path = require('path'),
14-
file = fs.realpathSync(process.argv[2]);
14+
file = process.argv[2];
1515

1616
if (!file) {
1717
yargs.showHelp();
1818
process.exit();
19-
} else if (!fs.existsSync(file)) {
20-
console.error(fn._[0], 'doesn\'t exist.');
19+
}
20+
21+
file = path.resolve(file);
22+
23+
if (!fs.existsSync(file)) {
24+
console.error(file, 'doesn\'t exist.');
25+
process.exit();
26+
} else if (!fs.lstatSync(file).isFile()) {
27+
console.error(file, 'is not a file.');
2128
process.exit();
2229
}
2330

@@ -41,5 +48,16 @@ var scope = new check.Scope({
4148
file: file
4249
});
4350

44-
console.log();
45-
check.traverse(check.astFromFile(scope.file, argv.o), scope);
51+
if (argv.j) {
52+
scope.log = function(type, node, name, value) {
53+
console.dir({
54+
type: type,
55+
pos: this.file + ':' + check.pos(node),
56+
name: name,
57+
value: value
58+
});
59+
};
60+
}
61+
62+
var ast = check.astFromFile(scope.file, argv.o);
63+
check.traverse(ast, scope);

0 commit comments

Comments
 (0)