Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('init: should output an error message if debug option is set and sourceContent is missing', function(t) {
var file = makeFile();
file.contents = new Buffer(sourceContent + '\n//# sourceMappingURL=helloworld4.js.map');
var history = [];
console.log('HOOKING');
var unhook = hookStd.stderr(function(s) {
history.push(s);
});
var pipeline = sourcemaps.init({loadMaps: true});
pipeline.on('data', function() {
unhook();
var hasRegex = function(regex){
return function(s){
return regex.test(s);
};
};
console.log(history);
t.ok(
history.some(
hasRegex(/No source content for "missingfile". Loading from file./g)), 'should log missing source content');
t.ok(history.some(hasRegex(/source file not found: /g)), 'should warn about missing file');
test('write: should output an error message if debug option is set and sourceContent is missing', function(t) {
var file = makeFile();
file.sourceMap.sources[0] += '.invalid';
delete file.sourceMap.sourcesContent;
var history = [];
var unhook = hookStd.stderr(function(s) {
history.push(s);
});
var pipeline = sourcemaps.write();
var hasRegex = function(regex){
return function(s){
return regex.test(s);
};
};
pipeline.on('data', function() {
unhook();
console.log(JSON.stringify(history));
t.ok(history.some(hasRegex(/No source content for "helloworld.js.invalid". Loading from file./g)), 'should log missing source content');
t.ok(history.some(hasRegex(/source file not found: /g)), 'should warn about missing file');
t.end();
}).write(file);
function readOutput (spinner, callback) {
let out = ''
const unhook = hookStd.stderr({silent: true}, output => {
out += output
})
spinner.start()
spinner.stop()
unhook()
callback(out)
}
alfy.debug = getEnv('debug') === '1';
alfy.icon = {
get: getIcon,
info: getIcon('ToolbarInfo'),
warning: getIcon('AlertCautionIcon'),
error: getIcon('AlertStopIcon'),
alert: getIcon('Actions'),
like: getIcon('ToolbarFavoritesIcon'),
delete: getIcon('ToolbarDeleteIcon')
};
loudRejection(alfy.error);
process.on('uncaughtException', alfy.error);
hookStd.stderr(alfy.error);