-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
* Instead of providing the binaries with the package, it'll only download the needed binary for the users system. * Will only build if the tests fail. * Move `build.js` into scripts since it's not part of the actual API. * Move binaries to `vendor` folder to keep it separate from the rest of the code. Fixes #504.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
*.log | ||
.DS_Store | ||
.sass-cache | ||
bin | ||
!bin/node-sass | ||
build | ||
lib-cov | ||
node_modules | ||
vendor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
Download = require('download'), | ||
status = require('download-status'); | ||
|
||
/** | ||
* Check if binaries exists | ||
* | ||
* @api private | ||
*/ | ||
|
||
function exists() { | ||
var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]; | ||
var name = process.platform + '-' + process.arch + '-' + v8; | ||
|
||
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) { | ||
if (exists) { | ||
return; | ||
} | ||
|
||
fetch(name); | ||
}); | ||
} | ||
|
||
/** | ||
* Fetch binaries | ||
* | ||
* @param {String} name | ||
* @api private | ||
*/ | ||
|
||
function fetch(name) { | ||
var download = new Download({ | ||
extract: true, | ||
mode: '777', | ||
strip: 1 | ||
}); | ||
|
||
var url = [ | ||
'https://github.com/sass/node-sass-binaries/raw/master/', | ||
name + '/binding.node' | ||
].join(''); | ||
|
||
download.get(url); | ||
download.dest(path.join(__dirname, '..', 'vendor', name)); | ||
download.use(status()); | ||
|
||
download.run(function(err) { | ||
if (err) { | ||
console.error(err.message); | ||
return; | ||
} | ||
|
||
console.log('Binary installed in ' + download.dest()); | ||
}); | ||
} | ||
|
||
/** | ||
* Skip if CI | ||
*/ | ||
|
||
if (process.env.CI || process.env.APPVEYOR) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
j15e
|
||
console.log('Skipping downloading binaries on CI builds'); | ||
return; | ||
} | ||
|
||
/** | ||
* Run | ||
*/ | ||
|
||
exists(); |
This file was deleted.
@kevva Skipping downloading binaries on CI builds is causing my CircleCI builds to fail for projects that depend on node-sass. Curious as to the reasoning for this, and if there's a recommended workaround?