Skip to content

Commit

Permalink
Build: Misc. improvements.
Browse files Browse the repository at this point in the history
* Remove tests from publishing. sass#683
  * Uses new strategy to validate binary after
    the download.
  * Moves mocha under dev-dependencies in
    package.json.
* Truncates the forth potion from v8 version
  as discussed in sass#710.
* Moves pangyp from dev to main dependencies in
  package.json.

Issue URLs: sass#683 and sass#710.
PR URL: sass#717.
  • Loading branch information
am11 committed Feb 27, 2015
1 parent b2d2b9a commit b1bc102
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 42 deletions.
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.log
.DS_Store
.sass-cache
build
lib-cov
node_modules
vendor
test
10 changes: 9 additions & 1 deletion lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ function getRuntimeInfo() {
*/

function getBinaryIdentifiableName() {
var v8Version = process.versions.v8;
var splitted = v8Version.split('.');

if (splitted.length === 4) {
splitted.pop();
v8Version = splitted.join('.');
}

return [process.platform, '-',
process.arch, '-',
process.versions.v8].join('');
v8Version].join('');
}

process.runtime = getRuntimeInfo();
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
"style"
],
"dependencies": {
"chalk": "^0.5.1",
"chalk": "^1.0.0",
"cross-spawn": "^0.2.6",
"gaze": "^0.5.1",
"get-stdin": "^4.0.1",
"meow": "^3.0.0",
"meow": "^3.1.0",
"mkdirp": "^0.5.0",
"mocha": "^2.1.0",
"nan": "^1.6.2",
"npmconf": "^2.1.1",
"object-assign": "^2.0.0",
"pangyp": "^2.1.0",
"request": "^2.53.0",
"sass-graph": "^1.0.3",
"shelljs": "^0.3.0"
Expand All @@ -61,7 +61,7 @@
"coveralls": "^2.11.2",
"jscoverage": "^0.5.9",
"jshint": "^2.6.0",
"mocha-lcov-reporter": "^0.0.1",
"pangyp": "^2.1.0"
"mocha": "^2.1.0",
"mocha-lcov-reporter": "^0.0.2"
}
}
60 changes: 24 additions & 36 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
var eol = require('os').EOL,
fs = require('fs'),
mkdir = require('mkdirp'),
Mocha = require('mocha');

path = require('path'),
spawn = require('child_process').spawn;

require('../lib/extensions');

/**
Expand Down Expand Up @@ -50,30 +50,27 @@ function afterBuild(options) {
*/

function build(options) {
var arguments = ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args);
var arguments = [path.join('node_modules', 'pangyp', 'bin', 'node-gyp'), 'rebuild'].concat(options.args);

console.log(['Building:', process.runtime.execPath].concat(arguments).join(' '));

var proc = spawn(process.runtime.execPath, arguments, {
stdio: [0, 1, 2]
});

proc.on('exit', function(code) {
if (code) {
if (code === 127) {
console.error([
'node-gyp not found! Please upgrade your install of npm!',
'You need at least 1.1.5 (I think) and preferably 1.1.30.'
].join(' '));
proc.on('exit', function(errorCode) {
if (!errorCode) {
afterBuild(options);
}

return;
}
if (errorCode === 127) {
console.error('node-gyp not found!');

console.error('Build failed');
return;
}

afterBuild(options);
console.error('Build failed');
return;
});
}

Expand Down Expand Up @@ -123,28 +120,19 @@ function testBinary(options) {
return build(options);
}

console.log('`' + process.sassBinaryName + '` exists; testing');
console.log('`' + process.sassBinaryName + '` exists; testing.');

var mocha = new Mocha({
ui: 'bdd',
timeout: 999999,
reporter: function() {}
});

mocha.addFile(path.resolve(__dirname, '..', 'test', 'api.js'));
mocha.grep(/should compile sass to css with file/).run(function (done) {
if (done !== 0) {
console.log([
'Problem with the binary.',
'Manual build incoming.',
'Please consider contributing the release binary to https://github.com/sass/node-sass-binaries for npm distribution.'
].join('\n'));
try {
require('../').renderSync({
data: 's: { a: ss }'
});

return build(options);
}
console.log('Binary is fine; exiting.');
} catch (e) {
console.log(['Problem with the binary.', 'Manual build incoming.'].join(eol));

console.log('Binary is fine; exiting');
});
return build(options);
}
});
}

Expand Down

0 comments on commit b1bc102

Please sign in to comment.