Closed timkelty closed 9 years ago
I think this is a https://github.com/SBoudrias/mem-fs-editor bug. You should file the bug there instead.
Can this be because the system try to copy a directory as a file?
@SBoudrias likely, as it works with globs like somedir/*
. I used to work, though.
I started learning to create my first generator today, following this tutorial.
http://yeoman.io/authoring/file-system.html
As soon as I added this section of code I got exactly the same error.
generators.Base.extend({ writing: function () { this.fs.copyTpl( this.templatePath('index.html'), this.destinationPath('public/index.html'), { title: 'Templating with Yeoman' } ); } });
I assumed I had done something wrong as I'm a newbie so finding this issue was useful. Hope it gets fixed soon as I'm guessing lots of people use that getting started guide.
I tried using the generator.template()
method to render a glob expression (generator.template("folder/**/*", 'folder', data)
) but actually it gives me another error:
TypeError: First argument needs to be a number, array or string. at new Buffer (buffer.js:188:15)
I did some digging in it and the error comes from this call in 'mem-fs-editor/actions/read.js':
file.contents = file.contents || new Buffer(options.defaults);
(line 11)
The reason being that option.defaults
is undefined.
This could be avoided by adding a value to the options.defaults
, but (and this is where yeoman comes in) the read()
method is invoked in the template()
method in 'yeoman-generator/lib/actions/actions.js' at the var body = this.engine(this.fs.read(source), data || this, options)
(line 191). Here the second parameter in the read()
method call (the options) is omitted, so it is not possible to correct this for the user of the generator.template()
method.
Who is finally to blame I guess is up to the yeoman/mem-fs-editor teams, but somehow the glob copying doesn't work.
This is now fix thanks to @blai - npm update
to grab the patch release.
I seem to be having this issue as well.... an example of a subgen is here https://github.com/payner35/generator-meteor-react/blob/master/view/index.js
$ yo meteor-react:view imaview Creating a new View for imaview
/usr/local/lib/node_modules/generator-meteor-react/templates/view/view.coffee /Users/gavin/Dropbox/git/test/client/views/imaview/imaview.coffee
events.js:72 throw er; // Unhandled 'error' event ^ TypeError: Cannot call method 'toString' of null at copy.process (/usr/local/lib/node_modules/generator-meteor-react/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy-tpl.js:11:34) at applyProcessingFunc (/usr/local/lib/node_modules/generator-meteor-react/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:12:16) at EditionInterface.exports._co...
if i install the package locally with npm link it works fine... just when i npm install from the remote package i get this error.
@payner35 Can you try running npm cache clean
and do npm install
again to install the generator?
does not seem to be a fix?
i do notice that Yeoman-generator is dependent on "mem-fs-editor": "^1.0.0" "name": "yeoman-generator", "version": "0.18.10",
should this not be bumped to at least 1.2.1 https://github.com/SBoudrias/mem-fs-editor/releases
is this the issue? https://github.com/SBoudrias/mem-fs-editor/issues/19
^
will get patches and minor releases.
Make sure to run npm update
and if you're using a npm mirror that this mirror is updated.
still no luck.. i have checked the package on another computer to see if the issue is local to my machine.. but i get the same result.
again if its worth noting. npm link works fine?
this is my gen https://github.com/payner35/generator-meteor-react
I looked at your code and found that https://github.com/payner35/generator-meteor-react/blob/master/view/index.js#L41 causes a copy
from the source file /generator-meteor-react/templates/view/view.coffee
(which does not exist if your generator-meteor-react is installed through npm).
The problem is in your package.json https://github.com/payner35/generator-meteor-react/blob/master/package.json#L26. You need to add a line to include your template folder in your npm install. So your package.json
should have this:
"files": [
"app",
"view",
"collection",
"component",
"templates"
]
Ah thanks for looking deeper into it @blai!
Great..!! thanks @blai and @SBoudrias.
Package working and updated ;)
Ran into this here: https://github.com/timkelty/generator-craft-plugin
This was working rather recently, but with a freshly re-installed yo, I get this:
I saw there were recent fixes for changes in
mem-fs-editor
, so I'm thinking it might be related?