From f5ea8a0f196afd4d7d8a19ca9e51a7e48ea8c681 Mon Sep 17 00:00:00 2001 From: Gabe Gorelick Date: Sat, 21 May 2016 16:49:46 -0400 Subject: [PATCH 1/2] Output error message on espree error --- lib/extract.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/extract.js b/lib/extract.js index 043782f..dd8fdca 100644 --- a/lib/extract.js +++ b/lib/extract.js @@ -179,6 +179,16 @@ var Extractor = (function () { } }); } catch (err) { + var errMsg = 'Error parsing'; + if (filename) { + errMsg += ' ' + filename; + } + if (err.lineNumber) { + errMsg += ' at line ' + err.lineNumber; + errMsg += ' column ' + err.column; + } + + console.warn(errMsg); return; } From d80313fc0e2e9d8a982fa47197176448b4864f09 Mon Sep 17 00:00:00 2001 From: Gabe Gorelick Date: Sat, 21 May 2016 17:12:59 -0400 Subject: [PATCH 2/2] Suppress parse error in test --- package.json | 3 ++- test/extract_javascript.js | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d26ed49..285c44e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "grunt-contrib-jshint": "~0.11.2", "grunt-contrib-watch": "~0.6.1", "grunt-jscs": "^1.8.0", - "grunt-mocha-cli": "^1.13.1" + "grunt-mocha-cli": "^1.13.1", + "sinon": "^1.17.4" }, "keywords": [ "angular", diff --git a/test/extract_javascript.js b/test/extract_javascript.js index 929ac53..c4f7b8c 100644 --- a/test/extract_javascript.js +++ b/test/extract_javascript.js @@ -1,6 +1,7 @@ 'use strict'; var assert = require('assert'); +var sinon = require('sinon'); var testExtract = require('./utils').testExtract; describe('Extracting from Javascript', function () { @@ -78,11 +79,23 @@ describe('Extracting from Javascript', function () { assert.deepEqual(catalog.items[1].references, ['test/fixtures/deeppath_catalog.js:4']); }); - it('supports invalid javascript syntax without exception', function () { - var files = [ - 'test/fixtures/deeppath_catalog_invalid.js' - ]; - testExtract(files); + describe('invalid javascript', function () { + beforeEach(function () { + sinon.stub(console, 'warn', function () { + // respect the rule of silence + }); + }); + + afterEach(function () { + console.warn.restore(); + }); + + it('should not throw an exception', function () { + var files = [ + 'test/fixtures/deeppath_catalog_invalid.js' + ]; + testExtract(files); + }); }); describe('from HTML