mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +00:00
Add symlink support.
This commit is contained in:
parent
fcaeb381fe
commit
7c58f0ea96
@ -80,6 +80,7 @@ Abstract theme representation.
|
|||||||
|
|
||||||
// Set up a hash of formats supported by this theme.
|
// Set up a hash of formats supported by this theme.
|
||||||
var formatsHash = { };
|
var formatsHash = { };
|
||||||
|
var that = this;
|
||||||
|
|
||||||
// Establish the base theme folder
|
// Establish the base theme folder
|
||||||
var tplFolder = PATH.join( this.folder, 'src' );
|
var tplFolder = PATH.join( this.folder, 'src' );
|
||||||
@ -110,7 +111,7 @@ Abstract theme representation.
|
|||||||
|
|
||||||
// We should have a valid output format now.
|
// We should have a valid output format now.
|
||||||
formatsHash[ outFmt ] =
|
formatsHash[ outFmt ] =
|
||||||
formatsHash[outFmt] || { outFormat: outFmt, files: [] };
|
formatsHash[outFmt] || { outFormat: outFmt, files: [], symLinks: that.formats[ outFmt ].symLinks };
|
||||||
|
|
||||||
// Create the file representation object.
|
// Create the file representation object.
|
||||||
var obj = {
|
var obj = {
|
||||||
@ -199,7 +200,11 @@ Abstract theme representation.
|
|||||||
|
|
||||||
// We should have a valid output format now.
|
// We should have a valid output format now.
|
||||||
formatsHash[ outFmt ] =
|
formatsHash[ outFmt ] =
|
||||||
formatsHash[outFmt] || { outFormat: outFmt, files: [] };
|
formatsHash[ outFmt ] || {
|
||||||
|
outFormat: outFmt,
|
||||||
|
files: [],
|
||||||
|
symLinks: that.formats[ outFmt ].symLinks
|
||||||
|
};
|
||||||
|
|
||||||
// Create the file representation object.
|
// Create the file representation object.
|
||||||
var obj = {
|
var obj = {
|
||||||
@ -235,12 +240,6 @@ Abstract theme representation.
|
|||||||
return fmt.ext !== 'css';
|
return fmt.ext !== 'css';
|
||||||
});
|
});
|
||||||
|
|
||||||
// Object.keys( formatsHash ).forEach(function(k){
|
|
||||||
// formatsHash[ k ].files.forEach(function(xhs){
|
|
||||||
// console.log(xhs.orgPath);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
return formatsHash;
|
return formatsHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ Template-based resume generator base for FluentCV.
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var FS = require( 'fs' )
|
var FS = require( 'fs-extra' )
|
||||||
, _ = require( 'underscore' )
|
, _ = require( 'underscore' )
|
||||||
, MD = require( 'marked' )
|
, MD = require( 'marked' )
|
||||||
, XML = require( 'xml-escape' )
|
, XML = require( 'xml-escape' )
|
||||||
@ -19,7 +19,7 @@ Template-based resume generator base for FluentCV.
|
|||||||
var _defaultOpts = {
|
var _defaultOpts = {
|
||||||
engine: 'underscore',
|
engine: 'underscore',
|
||||||
keepBreaks: true,
|
keepBreaks: true,
|
||||||
freezeBreaks: true,
|
freezeBreaks: false,
|
||||||
nSym: '&newl;', // newline entity
|
nSym: '&newl;', // newline entity
|
||||||
rSym: '&retn;', // return entity
|
rSym: '&retn;', // return entity
|
||||||
template: {
|
template: {
|
||||||
@ -87,7 +87,7 @@ Template-based resume generator base for FluentCV.
|
|||||||
if (!exists( tFolder )) {
|
if (!exists( tFolder )) {
|
||||||
tFolder = PATH.resolve( this.opts.theme );
|
tFolder = PATH.resolve( this.opts.theme );
|
||||||
if (!exists( tFolder )) {
|
if (!exists( tFolder )) {
|
||||||
throw { fluenterror: this.codes.themeNotFound, data: this.opts.theme };
|
throw { fluenterror: this.codes.themeNotFound, data: this.opts.theme};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,19 +102,43 @@ Template-based resume generator base for FluentCV.
|
|||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
curFmt.files.forEach(function(tplInfo){
|
curFmt.files.forEach(function(tplInfo){
|
||||||
|
if( tplInfo.action === 'transform' || tplInfo.action === null ) {
|
||||||
if( tplInfo.action === 'transform' ) {
|
if( tplInfo.action === 'transform' ) {
|
||||||
var cssInfo = { file: tplInfo.css ? tplInfo.cssPath : null, data: tplInfo.css || null };
|
var cssInfo = { file: tplInfo.css ? tplInfo.cssPath : null, data: tplInfo.css || null };
|
||||||
var mk = that.single( rez, tplInfo.data, that.format, cssInfo, that.opts );
|
var mk = that.single( rez, tplInfo.data, that.format, cssInfo, that.opts );
|
||||||
that.onBeforeSave && (mk = that.onBeforeSave( { mk: mk, theme: theme, outputFile: f } ));
|
that.onBeforeSave && (mk = that.onBeforeSave( { mk: mk, theme: theme, outputFile: f } ));
|
||||||
|
|
||||||
var thisFilePath = PATH.join(outFolder, tplInfo.orgPath);
|
var thisFilePath = PATH.join(outFolder, tplInfo.orgPath);
|
||||||
|
try {
|
||||||
MKDIRP.sync( PATH.dirname(thisFilePath) );
|
MKDIRP.sync( PATH.dirname(thisFilePath) );
|
||||||
console.log('Would save to ' + thisFilePath);
|
|
||||||
|
|
||||||
FS.writeFileSync( thisFilePath, mk, { encoding: 'utf8', flags: 'w' } );
|
FS.writeFileSync( thisFilePath, mk, { encoding: 'utf8', flags: 'w' } );
|
||||||
}
|
}
|
||||||
|
catch(ex) {
|
||||||
|
console.log(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( tplInfo.action === null ) {
|
||||||
|
var thisFilePath = PATH.join(outFolder, tplInfo.orgPath);
|
||||||
|
try {
|
||||||
|
MKDIRP.sync( PATH.dirname(thisFilePath) );
|
||||||
|
FS.copySync( tplInfo.path, thisFilePath );
|
||||||
|
}
|
||||||
|
catch(ex) {
|
||||||
|
console.log(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create symlinks
|
||||||
|
if( curFmt.symLinks ) {
|
||||||
|
Object.keys( curFmt.symLinks ).forEach( function(loc) {
|
||||||
|
var absLoc = PATH.join(outFolder, loc);
|
||||||
|
var absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
||||||
|
var type = PATH.parse( absLoc ).ext ? 'file' : 'junction'; // 'file', 'dir', or 'junction' (Windows only)
|
||||||
|
FS.symlinkSync( absTarg, absLoc, type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user