nystudio107 / generator-craftplugin

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

Update `fs` functions for node 12.11.1 #95

Closed mattstein closed 4 years ago

mattstein commented 4 years ago

Testing https://github.com/nystudio107/generator-craftplugin/pull/94 locally was tricky. Stepping node back to 6.17.1 led to a bunch of breakages, and yo craftplugin nearly worked until fs interactions, which would throw errors to the tune of

+ Creating Craft plugin folder generic
events.js:187
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
    at maybeCallback (fs.js:146:9)
    at Object.writeFile (fs.js:1245:14)
    at child.configuring (/path/to/generator-craftplugin/app/index.js:294:12)
    at /path/to/generator-craftplugin/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:131:23)
Emitted 'error' event on child instance at:
    at /path/to/generator-craftplugin/node_modules/yeoman-generator/lib/base.js:437:14
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:131:23)

Apparently fs methods differ slightly in node 12, so the changes in this PR allow yo craftplugin to work fully—and generate a plugin as expected—running node 12.11.1. (I alternatively tried updating the npm dependencies, but Yeoman 1.0 introduced breaking changes I wasn’t immediately sure how to resolve.)

Submitting as a PR since I’m not sure what kind of terrors this could introduce for pluginfactory.io.

mattstein commented 4 years ago

...and this is a duplicate of https://github.com/nystudio107/generator-craftplugin/pull/92.