nystudio107 / generator-craftplugin

generator-craftplugin is a Yeoman generator for Craft CMS plugins
MIT License
74 stars 30 forks source link

Breaks in newer versions of node #71

Closed cmalven closed 4 years ago

cmalven commented 5 years ago

I tried using the generator in node 10.8.0 today, and every time the generator fails with the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:127:9)
    at Object.writeFile (fs.js:1123:14)
    at child.configuring (/Users/cmalven/.nvm/versions/node/v10.8.0/lib/node_modules/generator-craftplugin/app/index.js:294:12)
    at /Users/cmalven/.nvm/versions/node/v10.8.0/lib/node_modules/generator-craftplugin/node_modules/yeoman-generator/lib/base.js:429:16
    at runCallback (timers.js:693:18)
    at tryOnImmediate (timers.js:664:5)
    at processImmediate (timers.js:646:5)
Emitted 'error' event at:
    at /Users/cmalven/.nvm/versions/node/v10.8.0/lib/node_modules/generator-craftplugin/node_modules/yeoman-generator/lib/base.js:437:14
    at runCallback (timers.js:693:18)
    at tryOnImmediate (timers.js:664:5)
    at processImmediate (timers.js:646:5)

Looking at the writeFile source code for the generator, it looks like that command doesn't actually have a callback param specified, but according to the most recent docs the callback param is required unless you're using writeFileSync.

I switched to node 8.11.0 and it worked fine, so could just be an API change in more recent node versions.

lukepearce commented 5 years ago

expands on #70

khalwat commented 4 years ago

Fixed this with writeFileSync() -> https://github.com/nystudio107/generator-craftplugin/commit/3d22216593d84ec809c6087115d5b5eeeb40312e