Skip to content

Commit

Permalink
Fix sass#775: Introduce SASS_BINARY_SITE environment variable
Browse files Browse the repository at this point in the history
Provide ability to locally mirror node-sass
binaries for various versions and platforms.

SASS_BINARY_SITE needs to be an URL pointing to
a collection of files organized like the Github
repository.

If SASS_BINARY_SITE is set to

 http://myhost:8080/local/node-sass-bin/

then

 http://myhost:8080/local/node-sass-bin/v3.0.0-beta.5/freebsd-x64-14_binding.node

should point to the FreeBSD 64 bit binary for node 0.12.0

The URL can be also specified as the --sass-binary-site
commandline option or in the package.json:

 "nodeSassConfig": {
   "binarySite": <url>
 }

Remove --sass-binary-url and friends.
  • Loading branch information
saper committed Apr 10, 2015
1 parent bccad58 commit d4397b8
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions lib/extensions.js
Expand Up @@ -50,7 +50,7 @@ function getRuntimeInfo() {
/**
* Get binary name.
* If environment variable SASS_BINARY_NAME or
* process aurgument --binary-name is provide,
* process argument --binary-name is provided,
* return it as is, otherwise make default binary
* name: {platform}-{arch}-{v8 version}.node
*
Expand All @@ -76,21 +76,40 @@ function getBinaryName() {
}

/**
* Retrieve the URL to fetch binary.
* If environment variable SASS_BINARY_URL
* is set, return that path. Otherwise make
* path using current release version and
* binary name.
* Determine the URL to fetch binary file from.
* By default feth from the node-sass distribution
* site on GitHub.
*
* The default URL can be overriden using
* the environment variable SASS_BINARY_SITE
* or a command line option --sass-binary-site:
*
* node scripts/install.js --sass-binary-site http://example.com/
*
* The URL should to the mirror of the repository
* laid out as follows:
*
* SASS_BINARY_SITE/
*
* v3.0.0-beta.4
* v3.0.0-beta.4/freebsd-x64-14_binding.node
* ....
* v3.0.0-beta.5
* v3.0.0-beta.5/freebsd-ia32-11_binding.node
* v3.0.0-beta.5/freebsd-x64-42_binding.node
* ... etc. for all supported versions and platforms
*
* @api private
*/

function getBinaryUrl() {
return flags['--sass-binary-url'] ||
package.nodeSassConfig ? package.nodeSassConfig.binaryUrl : null ||
process.env.SASS_BINARY_URL ||
['https://github.com/sass/node-sass/releases/download/v',
package.version, '/', sass.binaryName].join('');
return [
(
flags['--sass-binary-site'] ||
(package.nodeSassConfig ? package.nodeSassConfig.binarySite : null) ||
process.env.SASS_BINARY_SITE || 'https://github.com/sass/node-sass/releases/download'
), 'v' + package.version, sass.binaryName
].join('/');
}

/**
Expand Down Expand Up @@ -118,7 +137,7 @@ sass.versionInfo = getVersionInfo();
/**
* Get binary path.
* If environment variable SASS_BINARY_PATH or
* process aurgument --binary-path is provide,
* process argument --sass-binary-path is provided,
* select it by appending binary name, otherwise
* make default binary path using binary name.
* Once the primary selection is made, check if
Expand Down

0 comments on commit d4397b8

Please sign in to comment.