From 3896e0fad799fc4a0b4d36571ee6de365c3f7b28 Mon Sep 17 00:00:00 2001 From: Andrew Worcester Date: Thu, 26 Jan 2017 13:37:10 -0500 Subject: [PATCH] fixes an issue with plop.load resolving paths correctly --- package.json | 7 ++++--- src/modules/node-plop.js | 10 ++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 87fe9f79..c4abd804 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-plop", - "version": "0.5.4", + "version": "0.5.5", "description": "programmatic plopping for fun and profit", "main": "lib/index.js", "scripts": { @@ -45,7 +45,7 @@ "eslint-config-standard": "^6.2.1", "eslint-plugin-promise": "^3.3.1", "eslint-plugin-standard": "^2.0.1", - "plop-pack-fancy-comments": "^0.2.0", + "plop-pack-fancy-comments": "^0.2.1", "pre-commit": "^1.1.3" }, "dependencies": { @@ -58,7 +58,8 @@ "inquirer": "^1.2.0", "lodash.get": "^4.4.2", "mkdirp": "^0.5.1", - "pify": "^2.3.0" + "pify": "^2.3.0", + "resolve": "^1.2.0" }, "ava": { "files": [ diff --git a/src/modules/node-plop.js b/src/modules/node-plop.js index bd6d24e3..7f91a895 100644 --- a/src/modules/node-plop.js +++ b/src/modules/node-plop.js @@ -2,6 +2,7 @@ import path from 'path'; import inquirer from 'inquirer'; import handlebars from 'handlebars'; import _get from 'lodash.get'; +import resolve from 'resolve'; import bakedInHelpers from './baked-in-helpers'; import generatorRunner from './generator-runner'; @@ -67,14 +68,7 @@ function nodePlop(plopfilePath = '', plopCfg = {}) { }, loadCfg); targets.forEach(function (target) { - var targetPath; - - try { - targetPath = require.resolve(target); - } catch (err) { - targetPath = path.resolve(getPlopfilePath(), target); - } - + const targetPath = resolve.sync(target, {basedir: getPlopfilePath()}); const proxy = nodePlop(targetPath, config); const proxyDefaultInclude = proxy.getDefaultInclude() || {}; const includeCfg = includeOverride || proxyDefaultInclude;