diff --git a/.travis.yml b/.travis.yml index 28693b22f..a37430934 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js - +dist: trusty compiler: gcc sudo: false @@ -41,6 +41,11 @@ jobs: - stage: platform-test node_js: "0.10" os: linux + - stage: platform-test + node_js: "node" + env: + - NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/chakracore-release/ + os: linux addons: apt: diff --git a/appveyor.yml b/appveyor.yml index 87dc0ed8c..ed60132ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,44 +32,53 @@ - '%AppData%\npm-cache' environment: + # https://github.com/jasongin/nvs/blob/master/doc/CI.md + NVS_VERSION: 1.4.0 SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true matrix: - - nodejs_version: 0.10 + - NODEJS_VERSION: node/0.10 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 0.12 + - NODEJS_VERSION: node/0.12 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 1.0 + - NODEJS_VERSION: iojs/1 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 1 + - NODEJS_VERSION: iojs/2 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 2 + - NODEJS_VERSION: iojs/3 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 3 + - NODEJS_VERSION: node/4 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 4 + - NODEJS_VERSION: node/5 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 5 - GYP_MSVS_VERSION: 2013 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 6 + - NODEJS_VERSION: node/6 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - nodejs_version: 7 + - NODEJS_VERSION: node/7 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - nodejs_version: 8 + - NODEJS_VERSION: node/8 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - NODEJS_VERSION: chakracore/8 + GYP_MSVS_VERSION: 2015 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 install: - - ps: Install-Product node $env:nodejs_version $env:platform + # Install NVS + - git clone --branch v%NVS_VERSION% --depth 1 https://github.com/jasongin/nvs %LOCALAPPDATA%\nvs + - set PATH=%LOCALAPPDATA%\nvs;%PATH% + - nvs --version + # Install selected version of Node.js using NVS + - nvs add %NODEJS_VERSION% + - nvs use %NODEJS_VERSION% + - node --version - npm --version - npm install @@ -131,29 +140,41 @@ - '%AppData%\npm-cache' environment: + # https://github.com/jasongin/nvs/blob/master/doc/CI.md + NVS_VERSION: 1.4.0 SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true matrix: - - nodejs_version: 0.10 + - NODEJS_VERSION: node/0.10 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 0.12 + - NODEJS_VERSION: node/0.12 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 4 + - NODEJS_VERSION: node/4 GYP_MSVS_VERSION: 2013 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - - nodejs_version: 6 + - NODEJS_VERSION: node/6 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - nodejs_version: 7 + - NODEJS_VERSION: node/7 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - nodejs_version: 8 + - NODEJS_VERSION: node/8 GYP_MSVS_VERSION: 2015 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + - NODEJS_VERSION: chakracore/8 + GYP_MSVS_VERSION: 2015 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 install: - - ps: Install-Product node $env:nodejs_version $env:platform + # Install NVS + - git clone --branch v%NVS_VERSION% --depth 1 https://github.com/jasongin/nvs %LOCALAPPDATA%\nvs + - set PATH=%LOCALAPPDATA%\nvs;%PATH% + - nvs --version + # Install selected version of Node.js using NVS + - nvs add %NODEJS_VERSION% + - nvs use %NODEJS_VERSION% + - node --version - npm --version - npm install diff --git a/lib/extensions.js b/lib/extensions.js index 8681be11a..bdd80afc0 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -78,6 +78,23 @@ function getHumanNodeVersion(abi) { } } +/** + * Get the friendly name of the Javascript engine that Node environment being run + * is using + * + * @param {string} engine - Javascript engine value - `v8` or `chakracore` + * @return {Object} Returns same engine name or false if unmatched + * + * @api public + */ +function getHumanJsEngine(engine) { + switch (engine) { + case 'v8': return 'v8'; + case 'chakracore': return 'chakracore'; + default: return false; + } +} + /** * Get a human readable description of where node-sass is running to support * user error reporting when something goes wrong @@ -93,9 +110,10 @@ function getHumanEnvironment(env) { parts = binding.split('-'), platform = getHumanPlatform(parts[0]), arch = getHumanArchitecture(parts[1]), - runtime = getHumanNodeVersion(parts[2]); - - if (parts.length !== 3) { + runtime = getHumanNodeVersion(parts[2]), + jsEngine = getHumanJsEngine(parts[3]); + + if (parts.length !== 3 && !(parts.length === 4 && jsEngine !== 'undefined')) { return 'Unknown environment (' + binding + ')'; } @@ -196,10 +214,16 @@ function getBinaryName() { } binaryName = [ - platform, '-', - process.arch, '-', - process.versions.modules - ].join(''); + platform, + process.arch, + process.versions.modules, + ]; + + if (process.jsEngine === 'chakracore') { + binaryName = binaryName.concat(process.jsEngine); + } + + binaryName = binaryName.join('-'); } return [binaryName, 'binding.node'].join('_'); diff --git a/package.json b/package.json index a3bcbbc82..40f970272 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "meow": "^3.7.0", "mkdirp": "^0.5.1", "nan": "^2.3.2", - "node-gyp": "^3.3.1", + "node-gyp": "^3.6.0", "npmlog": "^4.0.0", "request": "^2.79.0", "sass-graph": "^2.2.4", diff --git a/scripts/build.js b/scripts/build.js index 7bbba5ee4..c683c7859 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -56,14 +56,20 @@ function afterBuild(options) { */ function build(options) { - var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat( - ['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) { - return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join(''); - })).concat(options.args); - - console.log('Building:', [process.execPath].concat(args).join(' ')); - - var proc = spawn(process.execPath, args, { + var nodeGyp = resolveNodeGyp(); + var nodeGypArgs = nodeGyp.args.concat([ + 'rebuild', + '--verbose', + '--libsass_ext=' + (process.env['LIBSASS_EXT'] || ''), + '--libsass_cflags=' + (process.env['LIBSASS_CFLAGS'] || ''), + '--libsass_ldflags=' + (process.env['LIBSASS_LDFLAGS'] || ''), + '--libsass_library=' + (process.env['LIBSASS_LIBRARY'] || ''), + ]) + .concat(options.args); + + console.log(['Building:', nodeGyp.exeName].concat(nodeGypArgs).join(' ')); + + var proc = spawn(nodeGyp.exeName, nodeGypArgs, { stdio: [0, 1, 2] }); @@ -83,6 +89,19 @@ function build(options) { }); } +/** + * Resolve node-gyp command to invoke + * + * @api private + */ +function resolveNodeGyp() { + var localNodeGypBin = require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')); + + return { + exeName: process.execPath, + args: [localNodeGypBin], + }; +} /** * Parse arguments *