[Pkg-javascript-commits] [node-source-map-support] 01/06: New upstream version 0.4.18+ds
Julien Puydt
julien.puydt at laposte.net
Mon Sep 11 06:52:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-source-map-support.
commit b1a16d6ec5e5e41f9f4b596198e67ecd553ac41c
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Mon Sep 11 08:46:00 2017 +0200
New upstream version 0.4.18+ds
---
package.json | 2 +-
source-map-support.js | 12 ++++++++++--
test.js | 22 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index 6f14242..de64c25 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "source-map-support",
"description": "Fixes stack traces for files with source maps",
- "version": "0.4.17",
+ "version": "0.4.18",
"main": "./source-map-support.js",
"scripts": {
"build": "node build.js",
diff --git a/source-map-support.js b/source-map-support.js
index 699fd22..abd8886 100644
--- a/source-map-support.js
+++ b/source-map-support.js
@@ -80,7 +80,11 @@ retrieveFileHandlers.push(function(path) {
}
} else if (fs.existsSync(path)) {
// Otherwise, use the filesystem
- contents = fs.readFileSync(path, 'utf8');
+ try {
+ contents = fs.readFileSync(path, 'utf8');
+ } catch (er) {
+ contents = '';
+ }
}
return fileContentsCache[path] = contents;
@@ -388,7 +392,11 @@ function getErrorSource(error) {
// Support files on disk
if (!contents && fs && fs.existsSync(source)) {
- contents = fs.readFileSync(source, 'utf8');
+ try {
+ contents = fs.readFileSync(source, 'utf8');
+ } catch (er) {
+ contents = '';
+ }
}
// Format the line from the original source code like node does
diff --git a/test.js b/test.js
index 4583581..80f0332 100644
--- a/test.js
+++ b/test.js
@@ -143,6 +143,28 @@ it('normal throw', function() {
]);
});
+/* The following test duplicates some of the code in
+ * `normal throw` but triggers file read failure.
+ */
+it('fs.readFileSync failure', function() {
+ compareStackTrace(createMultiLineSourceMap(), [
+ 'var fs = require("fs");',
+ 'var rfs = fs.readFileSync;',
+ 'fs.readFileSync = function() {',
+ ' throw new Error("no rfs for you");',
+ '};',
+ 'try {',
+ ' throw new Error("test");',
+ '} finally {',
+ ' fs.readFileSync = rfs;',
+ '}'
+ ], [
+ 'Error: test',
+ /^ at Object\.exports\.test \((?:.*[/\\])?line7\.js:1007:107\)$/
+ ]);
+});
+
+
it('throw inside function', function() {
compareStackTrace(createMultiLineSourceMap(), [
'function foo() {',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-source-map-support.git
More information about the Pkg-javascript-commits
mailing list