-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use sass binary url from .npmrc if available #1145
Conversation
Cool, that looks like something we've been looking for! |
That's cool, but let's get at least naming consistent. #1143 is a nice attempt to document those. Also in the implementation we should just wrap the names of all parameters with |
Totally agree. I hope The second point I didn't really get. What's your idea there? |
Firstly, thanks for your contribution @fh1ch, we appreciated. Secondly, some house keep. I the future it's preferred you open an issue to discuss new features before implementing them. Odds are something similar has previously been discussed, or the team may already have plans in the area of interest. With regards to configuration we do have plans for standardising on Specifically to this PR we currently support 3 ENV variable that affect the binary download and/or resolution process, |
I :cupid pull requests :) @fh1ch check this out https://github.com/sass/node-sass/blob/master/scripts/build.js#L133-L136
One just needs probably to stick |
@saper I also do not understand what we're accomplishing here. I assume you're referring to the following:
This however isn't adding We already support |
I'm not sure I follow this reasoning. We already have support for the |
I applied the .npmrc configuration possibility also to the other environment variables as proposed by @xzyfer. The're now also covered by documentation and runtime tests. |
@@ -173,22 +206,44 @@ describe('runtime parameters', function() { | |||
assert.equal(process.sass.binaryUrl.substr(0, URL.length), URL); | |||
}); | |||
}); | |||
describe('checking if environment variable overrides package.json', function() { | |||
describe('checking if environment variable overrides .npmrc configuration variable', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should be added in addition to the existing package.json
tests. The test you're removing here is still important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to avoid redundancy there. The test is still existing but tests that .npmrc parameters can override package.json parameters ( see checking if .npmrc configuration variable overrides package.json
). And checking if environment variable overrides .npmrc configuration variable
checks if env parameters can override .npmrc parameters. This covers the whole chain form a hierarchical point of view.
I can of course add the original tests again if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think either approach is correct. We now have 4 ways to set these configurations. Testing they get set is important, testing their precedence is most important. The better tests would be asserting, per variable, that precedence is respected.
describe('configuration precedence should be respected', () => {
describe('SASS_BINARY_PATH', () => {
beforeEach(() => {
process.env.SASS_BINARY_PATH = 'foo';
process.env.npm_config_sass_binary_path = 'bar';
require.cache[packagePath].exports.nodeSassConfig = { binaryPath: 'baz' };
require(extensionsPath);
});
it('environment variable', () => {
assert.equal(process.sass.binaryPath, 'baz');
});
it('npm config', () => {
process.env.npm_config_sass_binary_path = null;
assert.equal(process.sass.binaryPath, 'bar');
});
it('package.json', () => {
process.env.npm_config_sass_binary_path = null;
require.cache[packagePath].exports.nodeSassConfig = {};
assert.equal(process.sass.binaryPath, 'foo');
});
})
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is a much better solution. I will start refactoring all configuration unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're awesome!
This should also reduce some bloat from these specs! \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit tests are now implemented in the way you suggested. It's now much smaller and cleaner without decreasing the coverage. I'm hoping your happy with the current solution. Just tell me if there is anything else to do.
Amazing work! 😍 |
Thank you very much, I'm really humbled 😍 I'm glad if I can help to bring this awesome project a bit forward. |
If you're comfortable with git rebase I'd ask you to please squash these commits together
and
I the end there would be 3 commits
|
|
||
Variable name | .npmrc parameter | Process argument | Value | ||
-----------------|------------------|--------------------|------ | ||
SASS_BINARY_NAME | sass_binary_name | --binary-name | path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's --sass-binary-name
. At least I hope so :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. Thank you very much for the input. I will correct and push it when I'm rebasing the stuff.
On Wed, 16 Sep 2015, Michael Mifsud wrote:
I don't mind having those two together, so that we are 100% green |
No problem, I will quickly rebase that stuff as you two suggest it. |
Presumably the existing test should still pass with the new functionality. To be honest I'm fine squashing this all into 1 commit. It's all tightly related. |
4701e24
to
0e0b38d
Compare
There are now only 3 commits. Should a rebase them all into 1? |
On Wed, 16 Sep 2015, Fabio Huser wrote:
There are now only 3 commits. Should a rebase them all into 1?
Would make sense since Travis striked again 😄
I am just trying to quickly fix some bug in Travis tests
so I'd love more testing :)
|
Good to now 😄 Are these 3 commits now ok for you or should I squash them all together? |
On Wed, 16 Sep 2015, Fabio Huser wrote:
As they say those days, LGTM! |
Awesome! Just tell me if I can help with something. |
@fh1ch this is all good! Our plan is to ship in 3.4.0 hopefully in a couple weeks. The reason for 3.4.0 is that this is feature and by semver it should be a minor release. This is largely to help communicate to people which version of node-sass has which version of LibSass. We really appreciate your work and we're super keen to get it out in the wild ASAP. |
@xzyfer: Good to know, thanks 😄 It doesn't hurries for me so it's not that important in which release it gets. But it's nice to have libSass-3.3.0 in. Thank you very much guys, it was a pleasure for me contributing to this project. |
Use sass binary url from .npmrc if available
This PR adds the possibility to configure the sass-binary URL in the .npmrc configuration file (e.g.
sass_cdnurl=http://example.com/sass-binaries
). This is also used the same way in PhantomJS by pointing the download URL to a mirror without having to set an environment variable manually.