gl-format-compiler-error
Advanced tools
Comparing version 1.0.0 to 1.0.1
18
index.js
@@ -5,2 +5,3 @@ | ||
var shaderName = require('glsl-shader-name'); | ||
var addLineNumbers = require('add-line-numbers'); | ||
@@ -13,3 +14,3 @@ module.exports = formatCompilerError; | ||
var name = shaderName(src) || 'of unknown name (see npm glsl-shader-name)'; | ||
var typeName = 'unknown type'; | ||
@@ -20,7 +21,6 @@ if (type !== undefined) { | ||
var longForm = sprintf("Error in %s shader %s:\n", typeName, name); | ||
var longForm = sprintf('Error compiling %s shader %s:\n', typeName, name); | ||
var shortForm = sprintf("%s%s", longForm, errLog); | ||
var errorStrings = errLog.split('\n'); | ||
var errors = {}; | ||
@@ -30,7 +30,11 @@ | ||
var errorString = errorStrings[i]; | ||
if (errorString === '') continue; | ||
var lineNo = parseInt(errorString.split(':')[2]); | ||
if (isNaN(lineNo)) { | ||
throw new Error(sprintf('Could not parse error: %s', errorString)); | ||
} | ||
errors[lineNo] = errorString; | ||
} | ||
var lines = src.split('\n'); | ||
var lines = addLineNumbers(src).split('\n'); | ||
@@ -40,3 +44,3 @@ for (var i = 0; i < lines.length; i++) { | ||
var line = lines[i]; | ||
longForm += sprintf("%4d: %s\n", i+1, line); | ||
longForm += line + '\n'; | ||
if (errors[i+1]) { | ||
@@ -50,6 +54,6 @@ var e = errors[i+1]; | ||
return { | ||
long: longForm, | ||
short: shortForm | ||
long: longForm.trim(), | ||
short: shortForm.trim() | ||
}; | ||
} | ||
{ | ||
"name": "gl-format-compiler-error", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Formats a webgl glsl compiler error.", | ||
@@ -25,2 +25,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"add-line-numbers": "^1.0.1", | ||
"gl-constants": "^1.0.0", | ||
@@ -27,0 +28,0 @@ "glsl-shader-name": "^1.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5805
41
4
+ Addedadd-line-numbers@^1.0.1
+ Addedadd-line-numbers@1.0.1(transitive)
+ Addedpad-left@1.0.2(transitive)
+ Addedrepeat-string@1.6.1(transitive)