Comparing version 0.4.3 to 0.4.4
39
index.js
@@ -5,5 +5,13 @@ var kpc = require('node-kpc'); | ||
var path = require('path'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
module.exports = gulpKpc; | ||
function pad(n, width, z) { | ||
z = z || '0'; | ||
n = n + ''; | ||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; | ||
} | ||
function gulpKpc(options) { | ||
@@ -58,6 +66,33 @@ | ||
msg = msg.replace(/^Line\ [0-9]*\:\ /, ''); | ||
msg = msg + '\n ' + e.filename + ':' + e.lineNumber; | ||
var lines = fs.readFileSync(e.filename, 'utf8').split('\n'); | ||
var currentLine = lines[e.lineNumber-1]+'\n'; | ||
var prevLine = lines[e.lineNumber-2]+'\n' || ''; | ||
var nextLine = lines[e.lineNumber] + '\n' || ''; | ||
var padWidth = (e.lineNumber+1).toString().length; | ||
if (prevLine) { | ||
prevLine = pad(e.lineNumber-1, padWidth) + prevLine; | ||
} | ||
if (currentLine) { | ||
currentLine = pad(e.lineNumber, padWidth) + currentLine; | ||
} | ||
if (nextLine) { | ||
nextLine = pad(e.lineNumber+1, padWidth) + nextLine; | ||
} | ||
var textArrow = ''; | ||
var n = 0; | ||
do { | ||
textArrow += ' '; | ||
n+=1; | ||
} while(n < e.column - 1 + padWidth); | ||
textArrow += '^'; | ||
msg = util.format('%s\n-> %s:%s\n\n%s%s%s\n%s\n', msg, e.filename, e.lineNumber, prevLine, currentLine, textArrow, nextLine); | ||
} | ||
throw new gUtil.PluginError('gulp-kpc', msg || e, {showStack: false}); | ||
callback(new gUtil.PluginError('gulp-kpc', msg || e, {showStack: false})); | ||
return; | ||
} | ||
@@ -64,0 +99,0 @@ |
{ | ||
"name": "gulp-kpc", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "kpc plugin for gulp", | ||
@@ -20,6 +20,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"through2": "~0.4.1", | ||
"gulp-util": "~2.2.14", | ||
"node-kpc": "^0.3.11" | ||
"gulp-util": "^2.2.20", | ||
"node-kpc": "^0.3.11", | ||
"through2": "~0.4.1" | ||
} | ||
} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6496
4
95
1
Updatedgulp-util@^2.2.20