Commit dd0d743a by Adeel Mujahid

Merge pull request #509 from kevva/new-build

Revamp build steps
parents 014537ae d4b8f6b4
*.log *.log
.DS_Store .DS_Store
.sass-cache .sass-cache
bin
!bin/node-sass
build build
lib-cov lib-cov
node_modules node_modules
vendor
...@@ -13,7 +13,7 @@ function getBinding() { ...@@ -13,7 +13,7 @@ function getBinding() {
var candidates = [ var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'), path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'), path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
path.join(__dirname, '..', 'bin', name, 'binding.node') path.join(__dirname, '..', 'vendor', name, 'binding.node')
]; ];
var candidate = candidates.filter(fs.existsSync)[0]; var candidate = candidates.filter(fs.existsSync)[0];
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
"gypfile": true, "gypfile": true,
"scripts": { "scripts": {
"coverage": "node scripts/coverage.js", "coverage": "node scripts/coverage.js",
"install": "node lib/build.js", "install": "node scripts/install.js",
"prepublish": "node scripts/prepublish", "postinstall": "node scripts/build.js",
"pretest": "node_modules/.bin/jshint bin lib test", "pretest": "node_modules/.bin/jshint bin lib test",
"test": "node_modules/.bin/mocha test" "test": "node_modules/.bin/mocha test"
}, },
...@@ -44,14 +44,15 @@ ...@@ -44,14 +44,15 @@
"dependencies": { "dependencies": {
"chalk": "^0.5.1", "chalk": "^0.5.1",
"cross-spawn": "^0.2.3", "cross-spawn": "^0.2.3",
"download": "^3.1.2",
"download-status": "^2.1.0",
"get-stdin": "^3.0.0", "get-stdin": "^3.0.0",
"meow": "^2.0.0", "meow": "^2.0.0",
"mkdirp": "^0.5.0", "mkdirp": "^0.5.0",
"mocha": "^2.0.1", "mocha": "^2.0.1",
"nan": "^1.3.0", "nan": "^1.3.0",
"node-watch": "^0.3.4", "node-watch": "^0.3.4",
"object-assign": "^1.0.0", "object-assign": "^1.0.0"
"shelljs": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"coveralls": "^2.11.1", "coveralls": "^2.11.1",
......
#!/usr/bin/env node
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
spawn = require('child_process').spawn, spawn = require('child_process').spawn,
mkdir = require('mkdirp'),
Mocha = require('mocha'); Mocha = require('mocha');
/** /**
...@@ -14,24 +14,24 @@ var fs = require('fs'), ...@@ -14,24 +14,24 @@ var fs = require('fs'),
function afterBuild(options) { function afterBuild(options) {
var folder = options.debug ? 'Debug' : 'Release'; var folder = options.debug ? 'Debug' : 'Release';
var target = path.join(__dirname, '..', 'build', folder, 'binding.node'); var target = path.join(__dirname, '..', 'build', folder, 'binding.node');
var install = path.join(__dirname, '..', 'bin', options.bin, 'binding.node'); var install = path.join(__dirname, '..', 'vendor', options.bin, 'binding.node');
fs.mkdir(path.join(__dirname, '..', 'bin', options.bin), function (err) { mkdir(path.join(__dirname, '..', 'vendor', options.bin), function (err) {
if (err && err.code !== 'EEXIST') { if (err && err.code !== 'EEXIST') {
console.error(err.message); console.error(err.message);
process.exit(1); return;
} }
fs.stat(target, function (err) { fs.stat(target, function (err) {
if (err) { if (err) {
console.error('Build succeeded but target not found'); console.error('Build succeeded but target not found');
process.exit(1); return;
} }
fs.rename(target, install, function (err) { fs.rename(target, install, function (err) {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
process.exit(1); return;
} }
console.log('Installed in `' + install + '`'); console.log('Installed in `' + install + '`');
...@@ -61,11 +61,11 @@ function build(options) { ...@@ -61,11 +61,11 @@ function build(options) {
'You need at least 1.1.5 (I think) and preferably 1.1.30.' 'You need at least 1.1.5 (I think) and preferably 1.1.30.'
].join(' ')); ].join(' '));
process.exit(code); return;
} }
console.error('Build failed'); console.error('Build failed');
process.exit(code); return;
} }
afterBuild(options); afterBuild(options);
...@@ -120,7 +120,7 @@ function testBinary(options) { ...@@ -120,7 +120,7 @@ function testBinary(options) {
} }
if (!process.env.SKIP_NODE_SASS_TESTS) { if (!process.env.SKIP_NODE_SASS_TESTS) {
fs.stat(path.join(__dirname, '..', 'bin', options.bin, 'binding.node'), function (err) { fs.stat(path.join(__dirname, '..', 'vendor', options.bin, 'binding.node'), function (err) {
if (err) { if (err) {
return build(options); return build(options);
} }
......
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) {
console.log('Skipping downloading binaries on CI builds');
return;
}
/**
* Run
*/
exists();
#!/usr/bin/env node
/*jshint shelljs:true */
"use strict";
require('shelljs/make');
if (env["$CI"]) {
echo("Skipping prepublish on CI builds");
exit(0);
}
// Look for a local clone of
var NODE_SASS_BINARIES_DIR = "../node-sass-binaries";
if (!test("-e", NODE_SASS_BINARIES_DIR)) {
if (!which("git")) {
echo("Sorry, this script requires git");
exit(1);
}
// Clone the binary repo to the expected location
var NODE_SASS_DIR = pwd();
cd("..");
exec("git clone https://github.com/sass/node-sass-binaries.git")
cd(NODE_SASS_DIR);
}
echo("Copying binaries to bin");
cp("-Rf", NODE_SASS_BINARIES_DIR + "/*", "bin");
rm(["bin/LICENSE", "bin/README.md"]);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment