mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 20:37:08 +01:00
Fix generation glitches.
Fix output file name glitch, writing CSS files to destination folder, and an issue where the process would evaporate before PDF/PNG generation could complete.
This commit is contained in:
4
dist/cli/main.js
vendored
4
dist/cli/main.js
vendored
@ -224,9 +224,7 @@ Definition of the `main` function.
|
||||
|
||||
/* Success handler for verb invocations. Calls process.exit by default */
|
||||
|
||||
executeSuccess = function(obj) {
|
||||
_exitCallback(0);
|
||||
};
|
||||
executeSuccess = function(obj) {};
|
||||
|
||||
|
||||
/* Failure handler for verb invocations. Calls process.exit by default */
|
||||
|
8
dist/core/fresh-theme.js
vendored
8
dist/core/fresh-theme.js
vendored
@ -131,11 +131,12 @@ Definition of the FRESHTheme class.
|
||||
/* Load a single theme file. */
|
||||
|
||||
_loadOne = function(absPath, formatsHash, tplFolder) {
|
||||
var absPathSafe, act, idx, obj, outFmt, pathInfo, portion, ref, ref1, reg, res;
|
||||
var absPathSafe, act, defFormats, idx, isPrimary, obj, outFmt, pathInfo, portion, ref, ref1, reg, res;
|
||||
pathInfo = parsePath(absPath);
|
||||
absPathSafe = absPath.trim().toLowerCase();
|
||||
outFmt = '';
|
||||
act = 'copy';
|
||||
isPrimary = false;
|
||||
if (this.explicit) {
|
||||
outFmt = _.find(Object.keys(this.formats), function(fmtKey) {
|
||||
var fmtVal;
|
||||
@ -181,6 +182,10 @@ Definition of the FRESHTheme class.
|
||||
if (!this.explicit) {
|
||||
act = 'transform';
|
||||
}
|
||||
defFormats = require('./default-formats');
|
||||
isPrimary = _.some(defFormats, function(form) {
|
||||
return form.name === outFmt && pathInfo.extname !== '.css';
|
||||
});
|
||||
}
|
||||
formatsHash[outFmt] = formatsHash[outFmt] || {
|
||||
outFormat: outFmt,
|
||||
@ -191,6 +196,7 @@ Definition of the FRESHTheme class.
|
||||
}
|
||||
obj = {
|
||||
action: act,
|
||||
primary: isPrimary,
|
||||
path: absPath,
|
||||
orgPath: PATH.relative(tplFolder, absPath),
|
||||
ext: pathInfo.extname.slice(1),
|
||||
|
15
dist/generators/html-pdf-cli-generator.js
vendored
15
dist/generators/html-pdf-cli-generator.js
vendored
@ -6,7 +6,7 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, TemplateGenerator, _, engines,
|
||||
var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, SPAWN, TemplateGenerator, _, engines,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
@ -22,6 +22,8 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
|
||||
HMSTATUS = require('../core/status-codes');
|
||||
|
||||
SPAWN = require('../utils/safe-spawn');
|
||||
|
||||
|
||||
/**
|
||||
An HTML-driven PDF resume generator for HackMyResume. Talks to Phantom,
|
||||
@ -41,12 +43,14 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
|
||||
HtmlPdfCLIGenerator.prototype.onBeforeSave = function(info) {
|
||||
var safe_eng;
|
||||
if (info.ext !== 'html') {
|
||||
return info.mk;
|
||||
}
|
||||
safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||
if (safe_eng === 'phantom') {
|
||||
safe_eng = 'phantomjs';
|
||||
}
|
||||
if (_.has(engines, safe_eng)) {
|
||||
this.SPAWN = require('../utils/safe-spawn');
|
||||
this.errHandler = info.opts.errHandler;
|
||||
engines[safe_eng].call(this, info.mk, info.outputFile, this.onError);
|
||||
return null;
|
||||
@ -86,7 +90,7 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
var tempFile;
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
return this.SPAWN('wkhtmltopdf', [tempFile, fOut], false, on_error, this);
|
||||
SPAWN('wkhtmltopdf', [tempFile, fOut], false, on_error, this);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -100,10 +104,11 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
var destPath, scriptPath, sourcePath, tempFile;
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
scriptPath = SLASH(PATH.relative(process.cwd(), PATH.resolve(__dirname, '../utils/rasterize.js')));
|
||||
scriptPath = PATH.relative(process.cwd(), PATH.resolve(__dirname, '../utils/rasterize.js'));
|
||||
scriptPath = SLASH(scriptPath);
|
||||
sourcePath = SLASH(PATH.relative(process.cwd(), tempFile));
|
||||
destPath = SLASH(PATH.relative(process.cwd(), fOut));
|
||||
return this.SPAWN('phantomjs', [scriptPath, sourcePath, destPath], false, on_error, this);
|
||||
SPAWN('phantomjs', [scriptPath, sourcePath, destPath], false, on_error, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
5
dist/generators/template-generator.js
vendored
5
dist/generators/template-generator.js
vendored
@ -115,13 +115,14 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
genInfo.files.forEach(function(file) {
|
||||
var thisFilePath;
|
||||
file.info.orgPath = file.info.orgPath || '';
|
||||
thisFilePath = PATH.join(outFolder, file.info.orgPath);
|
||||
thisFilePath = file.info.primary ? f : PATH.join(outFolder, file.info.orgPath);
|
||||
if (file.info.action !== 'copy' && this.onBeforeSave) {
|
||||
file.data = this.onBeforeSave({
|
||||
theme: opts.themeObj,
|
||||
outputFile: thisFilePath,
|
||||
mk: file.data,
|
||||
opts: this.opts
|
||||
opts: this.opts,
|
||||
ext: file.info.ext
|
||||
});
|
||||
if (!file.data) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user