Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
linkedIn.people.me(function(err, $in) {
req.session.$in = $in;
resume = makeResume($in);
resumeSchema.validate(resume, function (result, validationErr) {
var exitCode = 0;
if (validationErr || result.valid !== true) {
console.error(validationErr);
console.error(result);
exitCode = 1;
} else {
var resumeString = JSON.stringify(resume, undefined, 2);
log('saving file resume.json:' + resumeString.length);
fs.writeFileSync(__dirname + '/resume.json', resumeString);
console.log('Done!');
}
res.render('index', { accessToken: req.session.accessToken, resume: resume, result: result });
process.exit(exitCode);
});
});
} else {
function validate(resumeData, callback) {
resumeSchema.validate(resumeData, function(report, errs) {
if (errs) {
console.log('TEST FAILED'.red);
errorFormatter(errs);
process.exit();
} else {
console.log('TEST SUCCESSFUL'.green);
console.log('Number of errors:'.cyan, report.errors.length);
console.log('To publish your resume at'.cyan, 'http://jsonresume.org', 'simply type the command'.cyan, 'node index publish (resume publish)');
process.exit();
}
});
}
module.exports = {
function publish(resumeData, force) {
resumeSchema.validate(resumeData, function(report, errs) {
if (errs && !force) {
console.log('Error: Resume failed to publish.'.red);
console.log('Reasons:');
console.log(validate.errorFormatter(errs));
console.log('For error troubleshooting type:'.cyan, 'node index test');
console.log('Or to try publish regardless of the error warning, type:'.cyan, 'node publish --force');
process.exit();
} else {
if (force) {
console.log('You resume.json did not pass formatting tests. Attempting to publish anyway...'.yellow);
}
console.log('publishing...');
publishSend(resumeData);
}
});
}
fs.readFileAsync(path.join(root, themeDirectory, 'package.json'), 'utf8').then(function (themePackageJson) {
var output = '';
output += 'Theme returned an error.';
output += '<pre>';
output += error.stack;
output += '</pre>';
output += '<h3>Theme Info</h3>';
output += '<pre>';
output += themePackageJson;
output += '</pre>';
output += '<p><strong>We just launched the official 0.0.0 version recently, please make sure you update before continuing.</strong></p>';
output += '<h3>Resume.json Validation Test</h3>';
delete options.resume._id;
delete options.resume.jsonresume;
delete options.resume.profiles;
schema.validate(options.resume, function(blah, err) {
output += '<pre>';
output += JSON.stringify(err, undefined, 4);
output += '</pre>';
res.send(output)
})
});
})