Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async config => {
const { params, plugins } = await buildParams(config);
// Connect to the stdout and process each line of the output using `stdOut` function
const unhook = hookStd({ silent: false }, stdOut);
try {
await compose([verifyEnvironment(), ...plugins])(params);
unhook();
return params;
} catch (err) {
unhook();
throw err;
}
};
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);
it('should log to the console', () => {
let out = '';
const unhook = hookStd.stdout({ silent: true }, output => {
out += output;
});
log.setLevel('info');
log.info('foobar');
unhook();
const expected = out.trim();
expected.should.containEql('info: foobar');
});
});
it("logs to the console", function() {
var out = '';
var unhook = hookStd.stdout({silent: true}, function(output) {
out += output;
});
log.setLevel('info');
log.info('foobar');
unhook();
var expected = out.trim();
expected.should.containEql('info: foobar');
});
});
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);