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

Commit ea78d16

Browse files
Caleb HooverCaleb Hoover
Caleb Hoover
authored and
Caleb Hoover
committed
Merge branch 'master' of https://github.com/coder13/Meta
2 parents c15fc78 + 0fb7b20 commit ea78d16

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

bin/check

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ var yargs = require('yargs')
55
.describe('v', 'Verbose flag. Will print all statements. Default is false.')
66
.describe('r', 'Recrusive flag. Will recursively check required files. Default is false.')
77
.describe('j', 'Will output as a tree. Default is true.')
8-
.describe('o', 'if -j, will output json into a file: <file>_log. If a file is given, outputs to that it. Default is false.')
8+
.describe('d', 'debug flag. Will output the file and line of the code being checked when an error is thrown')
9+
.alias('d', 'debug')
910
.showHelpOnFail(false);
11+
// .describe('o', 'if -j, will output json into a file: <file>_log. If a file is given, outputs to that it. Default is false.')
1012

1113
var colors = require('colors'),
1214
fs = require('fs'),
@@ -37,7 +39,12 @@ if (argv.h) {
3739
}
3840

3941
var check = require('../check.js');
40-
check.setFlags({verbose: argv.v, recursive: argv.r, json: argv.j});
42+
check.setFlags({
43+
verbose: argv.v,
44+
recursive: argv.r,
45+
json: argv.j,
46+
debug: argv.d
47+
});
4148
var Scope = check.Scope;
4249

4350
if (!argv.j)

check.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var sources = require('./danger.json').sources;
2020
var flags = module.exports.flags = {
2121
verbose: false,
2222
recursive: false,
23-
json: true
23+
json: true,
24+
debug: false
2425
};
2526

2627
var reports = module.exports.reports = [];
@@ -30,6 +31,7 @@ module.exports.setFlags = function(flags) {
3031
flags.verbose = flags.verbose;
3132
flags.recursive = flags.recursive;
3233
flags.json = flags.json || true;
34+
flags.debug = flags.debug;
3335

3436
if (flags.recursive) {
3537
// function to handle loading and traversing a file upon require()
@@ -177,11 +179,23 @@ traverse = module.exports.traverse = function(ast, scope) {
177179
Scope.log('SOURCES', ast, scope.sources);
178180
}
179181

180-
ast.body.forEach(function (node) {
181-
if (node.type == 'ExpressionStatement')
182-
node = node.expression;
183-
scope.resolveStatement(node);
184-
});
182+
if (flags.debug) {
183+
try {
184+
ast.body.forEach(function (node) {
185+
if (node.type == 'ExpressionStatement')
186+
node = node.expression;
187+
scope.resolveStatement(node);
188+
});
189+
} catch (e) {
190+
console.log(e);
191+
}
192+
} else {
193+
ast.body.forEach(function (node) {
194+
if (node.type == 'ExpressionStatement')
195+
node = node.expression;
196+
scope.resolveStatement(node);
197+
});
198+
}
185199

186200
if (flags.verbose && !flags.json)
187201
Scope.Scope.leaveScope();

0 commit comments

Comments
 (0)