Closed leeola closed 12 years ago
Looks like this happened between npm versions 0.2.2 and 0.4.0. 0.2.2 works, 0.4.0 doesn't.
Found the issue.
(typeof process !== 'undefined' && ~process.title.indexOf('node')) ? exports : {};
If your process does not have a title, Plates does not properly write to exports as it should.
Link: https://github.com/flatiron/plates/blob/e91463b65f5cd63accda77463852c7fca2c29814/lib/plates.js#L2
Is there a reason to not simply check the existence of exports?
;var Plates = (typeof exports !== 'undefined') ? exports : {};
@leeolayvar so a global named exports can easily exist in the browser. However an object named process
as well as it having a member named title
is a lot less likely. However, the formula for this should actually be...
typeof process !== 'undefined' && process.title) ? exports : {}
The problem with the way it was...
typeof process !== 'undefined' && ~process.title.indexOf('node')) ? exports : {};
Is that you're node.js process can be re-titled either by the user or sometimes by node.js (for instance when using the cluster module)
But you're process
object will always have a title. If you remove it, you'll break stuff.
Fixed in 96bccdd937c3ca579ea82cb882270b603d61430f and tagged at v0.4.4
Yea, I was discussing this with the folks in #nodejitsu. My question is, on Cloud9 (an IDE for JS/etc), process.title actually equals "". So this issue will still exist, since process will not be undefined, but process.title will be an empty string (and i believe return false, correct?)
.. hopefully this makes sense, i just woke up. heh
Edit: I read your question completely in reverse. I just woke up as well.
I was suffering from a momentary lapse of well known knowledge on account of even needing to think about it. Because for some reason Cloud9 does something special to the process title, the forumla will need to be...
;var Plates = (typeof process !== 'undefined' && typeof process.title !== 'undefined') ? exports : {};
The fix is committed.
Looks great :D
Yea, my discussion on IRC was simply trying to find who actually had the bug. Plates for expecting the title to exist, or Cloud9 for not having a title.
i recommend vim ;)
I actually switched to C9 from Vim :)
I prefer Vim also, but i'm trying out C9 out of curiosity. Plus, all of Vim tools were Python-centric.. JS is new territory to me :s. IDEs in the browser is nifty, even if not as fully featured as Vim yet.
i love vim ;) you should check out NERDTree (http://www.vim.org/scripts/script.php?script_id=1658) and powerline (https://github.com/Lokaltog/vim-powerline). they make vim sexy.
With a completely fresh project, running "npm install plates", and then running the example code of..
The following error is given:
Thoughts? Note that Plates also does not have the Map attribute either.