From 730b9796d38389cf6d83f36ea92e9bf5807df089 Mon Sep 17 00:00:00 2001 From: Eugene Kuzmenko Date: Thu, 14 Jul 2016 10:43:24 +0300 Subject: [PATCH] [fixed] `Compiler#fsRead` - do not proceed to reading the ".map" file after failing to read the main file --- docs/Compiler.html | 22 +++++- docs/Compiler.js.html | 14 ++-- docs/quicksearch.html | 2 +- lib/Compiler.js | 14 ++-- src/Compiler.js | 14 ++-- test/Compiler.spec.js | 155 ++++++++++++++++++++++++++++++------------ 6 files changed, 156 insertions(+), 65 deletions(-) diff --git a/docs/Compiler.html b/docs/Compiler.html index 036315f..d92e60f 100644 --- a/docs/Compiler.html +++ b/docs/Compiler.html @@ -679,7 +679,7 @@
Parameters:
@@ -704,6 +704,26 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +void + + + +
+
+ + +
Example
diff --git a/docs/Compiler.js.html b/docs/Compiler.js.html index 4d03056..4a79400 100644 --- a/docs/Compiler.js.html +++ b/docs/Compiler.js.html @@ -158,14 +158,10 @@

Source: Compiler.js

* @param {string} outPath - the output path * @param {ProgramData} data - processed application code with source maps * @param {Function} callback - a callback function - * @return {void} * @example * Compiler.writeAndCallDone('/path/to/an/input/file', '/path/to/the/output/file', data, callback); */ static writeAndCallDone(inPath: string, outPath: string, data: ProgramData, callback: () => void) { - if (!data.code) { - return Compiler.done(inPath, callback); - } Compiler.fsWrite(outPath, data, () => { Compiler.done(inPath, callback); }); @@ -180,10 +176,14 @@

Source: Compiler.js

* @param {string} path - the output path * @param {ProgramData} data - the data to write * @param {Function} callback - a callback function + * @return {void} * @example * Compiler.fsWrite('/path/to/an/output/file', data, callback); */ static fsWrite(path: string, data: ProgramData, callback: () => void) { + if (!data.code) { + return callback(); + } Compiler.mkdir(path, () => { writeFile(path, data.code, scriptErr => { if (scriptErr) { @@ -261,12 +261,12 @@

Source: Compiler.js

*/ fsRead(path: string, callback: ProgramDataCallback) { readFile(path, (scriptErr, scriptData) => { + if (scriptErr) { + return callback({code: '', map: ''}); + } readFile(`${path}.map`, 'utf8', (mapErr, mapData) => { const map = mapErr ? '' : mapData; - if (scriptErr) { - return callback({code: '', map}); - } if (!this.compress) { return callback({code: scriptData.toString('utf8'), map}); } diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 9a3fc7e..0ae2b4f 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@