From fae2b4e15d23b34b38efc270f28eaf1fedba81c9 Mon Sep 17 00:00:00 2001 From: Andrew Worcester Date: Mon, 21 Nov 2016 09:43:19 -0500 Subject: [PATCH] fixes for some error reporting issues --- src/modules/generator-runner.js | 6 +++--- src/modules/node-plop.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/generator-runner.js b/src/modules/generator-runner.js index e66bef6..e7fab02 100644 --- a/src/modules/generator-runner.js +++ b/src/modules/generator-runner.js @@ -117,14 +117,14 @@ export default function (plop) { // handle type if (action.type === 'add') { if (pathExists) { - throw failure(`File already exists: ${fileDestPath}`); + throw failure('File already exists'); } else { yield fspp.makeDir(path.dirname(fileDestPath)); yield fspp.writeFile(fileDestPath, plop.renderString(template, data)); } } else if (action.type === 'modify') { if (!pathExists) { - throw failure(`File does not exists: ${fileDestPath}`); + throw failure('File does not exists'); } else { var fileData = yield fspp.readFile(fileDestPath); fileData = fileData.replace(action.pattern, plop.renderString(template, data)); @@ -139,7 +139,7 @@ export default function (plop) { path: fileDestPath }; } catch(err) { - throw failure(JSON.stringify(err)); + throw failure(err.error || err.message || JSON.stringify(err)); } }); diff --git a/src/modules/node-plop.js b/src/modules/node-plop.js index 4799237..37fa1e2 100644 --- a/src/modules/node-plop.js +++ b/src/modules/node-plop.js @@ -109,7 +109,7 @@ function nodePlop(plopfilePath = '', plopCfg = {}) { } // look for a package.json file to use for the "pkg" helper - try { pkgJson = require(`${getDestBasePath()}/package.json`); } + try { pkgJson = require(path.join(getDestBasePath(), 'package.json')); } catch(error) { pkgJson = {}; } /////////