Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test require("dustjs-helpers") clobbers global dust object in node #73

Merged
merged 4 commits into from
Jul 10, 2014

Conversation

kate2753
Copy link
Contributor

@kate2753 kate2753 commented Mar 3, 2014

Updated test spec runner for node to test that require("dustjs-helpers") adds helpers into global.dust object. #72 has the context for this change

@prashn64
Copy link
Contributor

prashn64 commented Mar 3, 2014

lgtm

@jimmyhchan
Copy link
Contributor

see comment in #72 👎

@kate2753
Copy link
Contributor Author

kate2753 commented Mar 4, 2014

I think this change still applies. I'm not changing what this code does, just making what is going on here more visible.

Currently spec runner for node relies on dust being a global variable. Global dust variable is used in renderTestSpec.js and helpersTests.js.

If we wanted to change this it, we would update old and new test runners for node test\server.js and test\jasmine-test\server\specRunner.js not to have dust as a global. We would then have to explicitly declare dust variable in renderTestSpec.js and helpersTests.js . Something like

var dust = typeof exports !== 'undefined' ? require('dustjs-linkedin') : dust;

Is this approach better than what we have? To me it seems more complicated and harder to follow.

@jimmyhchan
Copy link
Contributor

I see. got confused with the solutions from #72. sorry for the 👎 . This makes sense.

@jimmyhchan
Copy link
Contributor

Do we use this for browser testing as well? we'll run into an issue with window vs global

@kate2753
Copy link
Contributor Author

kate2753 commented Mar 4, 2014

Yup, we use both renderTestSpec.js and helpersTests.js for browser testing. I guess we could wrap both of the files in UMD style wrapper.

@kate2753
Copy link
Contributor Author

kate2753 commented Mar 4, 2014

Updated the diff.
Moved module.exports=dust;, cleaned up node spec runners and added unit tests to test #72. Let me know if changes look good, otherwise I can go back to the code in original commit for this.

dust.helpers[key] = helpers[key];
}

if(typeof module !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check module or exports here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should. Updated.

@jimmyhchan
Copy link
Contributor

looks good otherwise.

@framp
Copy link

framp commented Jun 16, 2014

Is there any chance of this getting merged?

Issue #72 is breaking a lot of code (namely, several examples of various dust-helpers) and I find the following particularly ugly:

var dust = require('dustjs-linkedin');
//require('dustjs-helpers');
dust.helpers = require('dustjs-helpers').helpers; //HACK
require('dustmotes-provide');

Thank you

@prashn64
Copy link
Contributor

prashn64 commented Jul 9, 2014

Still looks good. Do you think this should be a patch, minor, or major release? I was thinking minor, but can you think of anything backwards incompatible?

@kate2753
Copy link
Contributor Author

I think minor bump is appropriate here since we've bumped up dust core from 2.3 to 2.4

This change is backward compatible with previous versions.

prashn64 added a commit that referenced this pull request Jul 10, 2014
Extend the dust.helpers object instead of  clobbering.
@prashn64 prashn64 merged commit a2a39b1 into LinkedInAttic:master Jul 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants