1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-03 12:57:08 +01:00

feat: convert: support multiple JRS versions

This commit is contained in:
hacksalot
2018-02-09 21:34:24 -05:00
parent 58fe46dc83
commit 7cfdb95a04
12 changed files with 109 additions and 22 deletions

View File

@ -109,14 +109,27 @@ Definition of the FRESHResume class.
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
*/
FreshResume.prototype.saveAs = function(filename, format) {
var newRep;
if (format !== 'JRS') {
FreshResume.prototype.saveAs = function(filename, format, version) {
var freshVersionReg, newRep, parts, safeFormat, safeVersion;
safeFormat = (format || 'FRESH').trim();
safeVersion = version || "0";
freshVersionReg = require('../utils/fresh-version-regex');
if (!freshVersionReg().test(safeFormat)) {
throw {
badVer: safeFormat
};
}
parts = safeFormat.split('@');
if (parts[0] === 'FRESH') {
this.imp.file = filename || this.imp.file;
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
} else {
newRep = CONVERTER.toJRS(this);
} else if (parts[0] === 'JRS') {
newRep = CONVERTER.toJRS(this, null, parts.length > 1 ? parts[1] : "1.0.0");
FS.writeFileSync(filename, JRSResume.stringify(newRep), 'utf8');
} else {
throw {
badVer: safeFormat
};
}
return this;
};

View File

@ -37,7 +37,8 @@ Status codes for HackMyResume.
invalidOptionsFile: 27,
optionsFileNotFound: 28,
unknownSchema: 29,
themeHelperLoad: 30
themeHelperLoad: 30,
invalidSchemaVersion: 31
};
}).call(this);