From b1bc102e902183a7ba2eb7ae440f0abe29919241 Mon Sep 17 00:00:00 2001 From: Adeel Date: Fri, 27 Feb 2015 15:59:09 +0200 Subject: [PATCH] Build: Misc. improvements. * Remove tests from publishing. #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 #710. * Moves pangyp from dev to main dependencies in package.json. Issue URLs: #683 and #710. PR URL: #717. --- .npmignore | 8 +++++++ lib/extensions.js | 10 +++++++- package.json | 10 ++++---- scripts/build.js | 60 +++++++++++++++++++---------------------------- 4 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..55b41ebd5 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +*.log +.DS_Store +.sass-cache +build +lib-cov +node_modules +vendor +test diff --git a/lib/extensions.js b/lib/extensions.js index a902e7dba..1bbe5e053 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -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(); diff --git a/package.json b/package.json index 0aed9c2fd..673d9059c 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" } } diff --git a/scripts/build.js b/scripts/build.js index 7d74b4183..57e67ee2c 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -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'); /** @@ -50,7 +50,7 @@ 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(' ')); @@ -58,22 +58,19 @@ function build(options) { 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; }); } @@ -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); + } }); }