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);
}
});
}
}, function(er, email) {
if (er) {
console.log();
process.exit();
}
resumeJson.basics.name = name;
resumeJson.basics.email = email;
fs.writeFileSync(process.cwd() + '/resume.json', JSON.stringify(resumeJson, undefined, 2));
console.log('\nYour resume.json has been created!'.green);
console.log('');
console.log('To generate a formatted .html .md .txt or .pdf resume from your resume.json');
console.log('type: `resume export [someFileName]` including file extension eg: `resume export myresume.html`');
console.log('\nYou can optionally specify an available theme for html and pdf resumes using the --theme flag.');
console.log('Example: `resume export myresume.pdf --theme flat`');
console.log('Or simply type: `resume export` and follow the prompts.');
console.log('');
process.exit();
callback(true);
});
}, function(er, email) {
if (er) {
console.log();
process.exit();
}
resumeJson.basics.name = name;
resumeJson.basics.email = email;
fs.writeFileSync(process.cwd() + '/resume.json', JSON.stringify(resumeJson, undefined, 2));
console.log('\nYour resume.json has been created!'.green);
console.log('');
console.log('To generate a formatted .html .md .txt or .pdf resume from your resume.json');
console.log('type: `resume export [someFileName]` including file extension eg: `resume export myresume.html`');
console.log('\nYou can optionally specify an available theme for html and pdf resumes using the --theme flag.');
console.log('Example: `resume export myresume.pdf --theme flat`');
console.log('Or simply type: `resume export` and follow the prompts.');
console.log('');
process.exit();
callback(true);
});
});
}, function(er, email) {
if (er) {
console.log();
process.exit();
}
resumeJson.basics.name = name;
resumeJson.basics.email = email;
fs.writeFileSync(process.cwd() + '/resume.json', JSON.stringify(resumeJson, undefined, 2));
console.log('\nYour resume.json has been created!'.green);
console.log('');
console.log('To generate a formatted .html .md .txt or .pdf resume from your resume.json');
console.log('type: `resume export [someFileName]` including file extension eg: `resume export myresume.html`');
console.log('\nYou can optionally specify an available theme for html and pdf resumes using the --theme flag.');
console.log('Example: `resume export myresume.pdf --theme flat`');
console.log('Or simply type: `resume export` and follow the prompts.');
console.log('');
process.exit();
callback(true);
});
});
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)
})
});
})