mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-15 10:07:07 +01:00
Refactor verbs to separate files.
This commit is contained in:
30
src/verbs/convert.js
Normal file
30
src/verbs/convert.js
Normal file
@ -0,0 +1,30 @@
|
||||
(function(){
|
||||
|
||||
var loadSourceResumes = require('../core/load-source-resumes');
|
||||
|
||||
/**
|
||||
Convert between FRESH and JRS formats.
|
||||
*/
|
||||
module.exports = function convert( src, dst, opts, logger ) {
|
||||
var _log = logger || console.log;
|
||||
if( !src || !src.length ) { throw { fluenterror: 6 }; }
|
||||
if( !dst || !dst.length ) {
|
||||
if( src.length === 1 ) { throw { fluenterror: 5 }; }
|
||||
else if( src.length === 2 ) { dst = [ src[1] ]; src = [ src[0] ]; }
|
||||
else { throw { fluenterror: 5 }; }
|
||||
}
|
||||
if( src && dst && src.length && dst.length && src.length !== dst.length ) {
|
||||
throw { fluenterror: 7 };
|
||||
}
|
||||
var sheets = loadSourceResumes( src, _log );
|
||||
sheets.forEach(function(sheet, idx){
|
||||
var sourceFormat = sheet.imp.orgFormat === 'JRS' ? 'JRS' : 'FRESH';
|
||||
var targetFormat = sourceFormat === 'JRS' ? 'FRESH' : 'JRS';
|
||||
_log( 'Converting '.useful + sheet.imp.fileName.useful.bold + (' (' +
|
||||
sourceFormat + ') to ').useful + dst[0].useful.bold +
|
||||
(' (' + targetFormat + ').').useful );
|
||||
sheet.saveAs( dst[idx], targetFormat );
|
||||
});
|
||||
};
|
||||
|
||||
}());
|
Reference in New Issue
Block a user