diff --git a/History.md b/History.md index b3f7ef6..a914bd7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +1.8.0 / 2017-1-12 +================== + * Add verbose mode with IRON_DEBUG + * Fix file/path handling + 1.7.0 / 2017-1-12 ================== * fix command proxying (debug, shell, mongo, etc) diff --git a/lib/tools/file_system.js b/lib/tools/file_system.js index 4d93552..63f498e 100644 --- a/lib/tools/file_system.js +++ b/lib/tools/file_system.js @@ -14,6 +14,8 @@ module.exports = {}; * needed. */ module.exports.createFile = function createFile(filepath, data, opts) { + this.logDebug('createFile', filepath, opts); + opts = opts || {}; try { var pathParts = path.normalize(filepath).split(path.sep); @@ -144,12 +146,13 @@ module.exports.pathFromNpmModule = function pathFromNpmModule(/* path parts */) * For example, given foo.bar.baz, returns { type: 'bar', engine: 'baz' } */ module.exports.engineAndTypeFromFilepath = function engineAndTypeFromFilepath(srcpath) { - var re = /\.([A-Za-z0-9]+)/g; + var re = /\.([A-Za-z0-9.]+)$/g; var matches = srcpath.match(re); + matches = matches && matches[0].split('.', 3); if (!matches) return { type: undefined, engine: undefined }; - // matches can be an array of n length. I'll assume the last entry is the + // matches can be an array of length 2. I'll assume the last entry is the // engine, and the one before that the type. If there's only one entry I'll // assume the engine and type are the same. For example, template.js.js is // equivalent to template.js @@ -162,6 +165,8 @@ module.exports.engineAndTypeFromFilepath = function engineAndTypeFromFilepath(sr if (type) type = type.replace('.', ''); + this.logDebug('engineAndTypeFromFilepath', matches, srcpath, engine, type); + return { type: type, engine: engine @@ -197,12 +202,14 @@ module.exports.rewriteSourcePathForEngine = function rewriteSourcePathForEngine( return srcpath; var engine = config.engines[engineAndType.type]; - var findTypeRe = new RegExp(fileType + '\\S*$'); + var findTypeRe = new RegExp('\\.' + fileType + '\\S*$'); + + this.logDebug('rewriteSourcePathForEngine', engineAndType, findTypeRe, engine, fileType); if (engine === fileType) - return srcpath.replace(findTypeRe, fileType); + return srcpath.replace(findTypeRe, '.' + fileType); else - return srcpath.replace(findTypeRe, fileType + '.' + engine); + return srcpath.replace(findTypeRe, '.' + fileType + '.' + engine); return ret; }; @@ -223,12 +230,14 @@ module.exports.rewriteDestinationPathForEngine = function rewriteDestinationPath // replace everything after the file type with the new // engine extensions - var replaceTypeWithEngineRe = new RegExp(fileType + '\\S*$'); + var replaceTypeWithEngineRe = new RegExp('\\.' + fileType + '\\S*$'); + + this.logDebug('rewriteDestinationPathForEngine', destpath, fileType, engine, replaceTypeWithEngineRe); if (!fileType || !engine) return destpath; else - return destpath.replace(replaceTypeWithEngineRe, engine); + return destpath.replace(replaceTypeWithEngineRe, '.' + engine); }; /** @@ -297,6 +306,8 @@ module.exports.pathFromProject = function pathFromProject(/* path parts */) { module.exports.pathFromApp = function pathFromApp(/* path parts */) { var srcpath = this.rewriteSourcePathForEngine.apply(this, arguments); var appDirectory = this.findAppDirectory(); + + this.logDebug('pathFromApp', appDirectory, srcpath); return appDirectory ? path.join(appDirectory, srcpath) : false; }; @@ -365,7 +376,9 @@ module.exports.templateContent = function templateContent(srcpath, context) { module.exports.template = function template(srcpath, destpath, context) { var renderedTemplate = this.templateContent(srcpath, context) + '\n'; destpath = this.rewriteDestinationPathForEngine(destpath); - var ret = this.createFile(destpath, renderedTemplate) + var ret = this.createFile(destpath, renderedTemplate); + + this.logDebug('template', destpath); return ret; }; diff --git a/package.json b/package.json index af244aa..54940f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iron-meteor", - "version": "1.7.0", + "version": "1.8.0", "description": "A command line tool for scaffolding Meteor applications.", "homepage": "https://github.com/iron-meteor/iron-cli", "bugs": {