plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.12k stars 277 forks source link

Plop is not a function #383

Closed devotox closed 1 year ago

devotox commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch node-plop@0.31.1 for the project I'm working on.

yarn run v1.22.19
$ npx ts-node ./node_modules/plop/bin/plop.js --plopfile ./plop/model/plopfile.ts 'Delete Model'
[PLOP] Something went wrong with reading your plop file TypeError: plop is not a function
    at nodePlop (file:///Users/devonte/Documents/Shares/shares/projects/app/node_modules/node-plop/src/node-plop.js:271:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Liftoff.run (file:///Users/devonte/Documents/Shares/shares/projects/app/node_modules/plop/src/plop.js:56:12)
✨  Done in 6.12s.

Here is the diff that solved my problem:

diff --git a/node_modules/node-plop/src/node-plop.js b/node_modules/node-plop/src/node-plop.js
index 043bd12..9d46392 100644
--- a/node_modules/node-plop/src/node-plop.js
+++ b/node_modules/node-plop/src/node-plop.js
@@ -266,7 +266,7 @@ async function nodePlop(plopfilePath = "", plopCfg = {}) {
     const plop =
       typeof plopFileExport === "function"
         ? plopFileExport
-        : plopFileExport.default;
+        : plopFileExport.default.default || plopFileExport.default;

     await plop(plopfileApi, plopCfg);
   } else {

This issue body was partially generated by patch-package.

crutchcorn commented 1 year ago

Can you show your Plopfile you were using that required this patch?

crutchcorn commented 1 year ago

Closing as there's no minimal repro