Comparing version 1.0.5 to 1.0.6
#!/usr/bin/env node | ||
var args = require('minimist')(process.argv.slice(2)) | ||
var pump = require('pump') | ||
/* | ||
@@ -16,3 +16,3 @@ cat stacks.out | perf-sym <pid> | ||
require('./')(Object.assign(args, { | ||
var stream = require('./')(Object.assign(args, { | ||
pid: args._[0], | ||
@@ -32,2 +32,4 @@ internal: { | ||
} | ||
}) | ||
}) | ||
pump(process.stdin, stream, process.stdout) |
95
index.js
@@ -21,3 +21,3 @@ var fs = require('fs') | ||
if (notFound(mapFile)) return | ||
if (notFound(mapFile, opts)) return | ||
@@ -30,59 +30,70 @@ var map = fs.readFileSync(mapFile, 'utf8') | ||
pump( | ||
process.stdin, | ||
split(function(line) { | ||
var match | ||
var res | ||
var p | ||
var stream = split(function(line) { | ||
var match | ||
var res | ||
var p | ||
if (!(match = line.match(hexRx))) { | ||
errors++ | ||
if (!(match = line.match(hexRx))) { | ||
errors++ | ||
return line + '\n' | ||
} | ||
if (res = resolver.resolve(match[1])) { | ||
found++ | ||
line = line | ||
.replace(hexRx, (keepAddr ? '$1 ' : '') + res.symbol) | ||
.replace(optRx, '~*') | ||
.replace(frameRx, '$1') | ||
return line + '\n' | ||
} | ||
if (res = resolver.resolve(match[1])) { | ||
found++ | ||
line = line | ||
.replace(hexRx, (keepAddr ? '$1 ' : '') + res.symbol) | ||
.replace(optRx, '~*') | ||
.replace(frameRx, '$1') | ||
if (relative) { | ||
p = line.trim().split(' ').slice(1).join(' ') | ||
if (p && (p[0] === '/' || p[0] === '.')) { | ||
line = line.replace(p, path.relative(relative, p)) | ||
} | ||
if (relative) { | ||
p = line.trim().split(' ').slice(1).join(' ') | ||
if (p && (p[0] === '/' || p[0] === '.')) { | ||
line = line.replace(p, path.relative(relative, p)) | ||
} | ||
return internal(line, opts.internal) ? '' : line + '\n' | ||
} | ||
}), | ||
process.stdout | ||
) | ||
return internal(line, opts.internal) ? '' : line + '\n' | ||
} | ||
}) | ||
eos(process.stdin, function () { | ||
process.stdout.write('\n\n') //<-- important final line | ||
stream.on('pipe', function (src) { | ||
if (!opts.silent) { | ||
eos(src, function () { | ||
console.error('symbols found', found) | ||
console.error('symbols not found', errors) | ||
console.error('done') | ||
}) | ||
} | ||
console.error('symbols found', found) | ||
console.error('symbols not found', errors) | ||
console.error('done') | ||
stream.pipe = (function (pipe) { | ||
return function (dest) { | ||
eos(src, function () { | ||
dest.write('\n\n') //<-- important final line | ||
}) | ||
return pipe.apply(stream, arguments) | ||
} | ||
}(stream.pipe)) | ||
}) | ||
return stream | ||
} | ||
function notFound(file) { | ||
function notFound(file, opts) { | ||
if (!fs.existsSync(file)|| !fs.statSync(file).size) { | ||
console.error([ | ||
, | ||
'There should be a ' + file + ' file (with a size greater than zero)', | ||
'It\'s either not there or it\'s empty, make sure you ran your process with', | ||
'--perf-basic-prof, and make sure to clean up when process receives a SIGINT', | ||
'see the on-sigint and close-server-on-sigint modules for example', | ||
, | ||
].join('\n')) | ||
if (!opts.silent) { | ||
console.error([ | ||
, | ||
'There should be a ' + file + ' file (with a size greater than zero)', | ||
'It\'s either not there or it\'s empty, make sure you ran your process with', | ||
'--perf-basic-prof, and make sure to clean up when process receives a SIGINT', | ||
'see the on-sigint and close-server-on-sigint modules for example', | ||
, | ||
].join('\n')) | ||
} | ||
return true | ||
} | ||
} |
{ | ||
"name": "perf-sym", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Translate symbol names generated by `--basic-perf-prof` into JavaScript names", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9173
125
0