aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.js
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2016-10-19 07:54:40 -0500
committerMatt Godbolt <matt@godbolt.org>2016-10-19 17:12:43 -0500
commita0be851fcb78ed974982868f1543f56c61e1519f (patch)
tree57e820a1b0884a6608fb5d9eb6a97b1c3f442642 /lib/utils.js
parent444d75100d5a1e7f8211f96a84a9af88d5ff6747 (diff)
downloadcompiler-explorer-a0be851fcb78ed974982868f1543f56c61e1519f.tar.gz
compiler-explorer-a0be851fcb78ed974982868f1543f56c61e1519f.zip
Parse stdout/stderr on the server side
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/utils.js b/lib/utils.js
index c520be391..6eeb90d36 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -22,6 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
+var _ = require('underscore-node');
+
var tabsRe = /\t/g;
function expandTabs(line) {
@@ -34,5 +36,26 @@ function expandTabs(line) {
return " ".substr(spacesNeeded);
});
}
+exports.expandTabs = expandTabs;
-exports.expandTabs = expandTabs; \ No newline at end of file
+function parseOutput(lines) {
+ // TODO: better splitting here; handle Windows; no hardcoded paths,
+ // maybe filter out the name itself if it matches
+ var re = /^\/tmp\/[^:]+:([0-9]+)(:([0-9]+))?:\s+(.*)/;
+ // var windowsRe = /^C:\\Users\\[^(]+\(([0-9]+)\):\s+(.*)/;
+ var result = [];
+ _.each(lines.split('\n'), function (line) {
+ line = line.trim();
+ if (line !== "") {
+ var match = line.match(re);
+ if (match) {
+ result.push({line: parseInt(match[1]), text: match[4].trim()});
+ } else {
+ // match = line.match(windowsRe);
+ result.push({text: line});
+ }
+ }
+ });
+ return result;
+}
+exports.parseOutput = parseOutput; \ No newline at end of file