Commit 94168369 by Adeel Mujahid

Merge pull request #660 from am11/master

Misc. Fixes
parents fe1d59f5 b48d5d6a
......@@ -6,11 +6,12 @@ compiler:
- gcc
node_js:
- "0.10"
- "0.11"
- "0.12"
- iojs
matrix:
fast_finish: true
allow_failures:
- node_js: "0.11"
- node_js: iojs
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
- sudo apt-get update;
......
......@@ -6,18 +6,21 @@ init:
environment:
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
matrix:
# node.js
- nodejs_version: 0.10
- nodejs_version: 0.11
- nodejs_version: 0.12
# io.js
- nodejs_version: "1.1"
install:
- ps: Install-Product node $env:nodejs_version
- cmd: SET PATH=C:\python27;%PATH%
- git submodule update --init --recursive
- ps: npm install --msvs_version=2013
test_script:
- node --version
- npm --version
test_script:
- npm test
build: off
......@@ -10,19 +10,22 @@ var semver = require('semver'),
function getRuntimeName() {
return process.execPath
.split(/[\\/]+/).pop()
.split('.')[0];
.split('.').shift();
}
/**
* Get unique name of binary for current platform
*
* @api public
* @api private
*/
module.exports.getBinaryIdentifiableName = function() {
return process.platform + '-' +
process.arch + '-' +
getRuntimeName() + '-' +
runtimeVersion.major + '.' +
runtimeVersion.minor;
};
function getBinaryIdentifiableName() {
return [process.platform, '-',
process.arch, '-',
getRuntimeName(), '-',
runtimeVersion.major, '.',
runtimeVersion.minor].join('');
}
process.runtime = getRuntimeName();
process.sassBinaryName = getBinaryIdentifiableName();
var fs = require('fs'),
path = require('path'),
utils = require('./utils');
path = require('path');
require('./extensions');
/**
* Get binding
......@@ -12,10 +13,10 @@ function getBinding() {
var candidates = [
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'vendor', utils.getBinaryIdentifiableName(), 'binding.node')
path.join(__dirname, '..', 'vendor', process.sassBinaryName, 'binding.node')
];
var candidate = candidates.filter(fs.existsSync)[0];
var candidate = candidates.filter(fs.existsSync).shift();
if (!candidate) {
throw new Error('`libsass` bindings not found. Try reinstalling `node-sass`?');
......@@ -146,12 +147,7 @@ function getOptions(options) {
var success = options.success;
options.error = function(err, code) {
try {
err = JSON.parse(err);
} catch (e) {
err = { message: err };
}
err.code = code;
if (error) {
......@@ -166,7 +162,7 @@ function getOptions(options) {
if (success) {
success({
css: result.css,
map: result.sourceMap,
map: result.map,
stats: stats
});
}
......
......@@ -64,6 +64,6 @@
"jscoverage": "^0.5.9",
"jshint": "^2.6.0",
"mocha-lcov-reporter": "^0.0.1",
"pangyp": "^2.0.2"
"pangyp": "^2.1.0"
}
}
......@@ -2,8 +2,9 @@ var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
mkdir = require('mkdirp'),
Mocha = require('mocha'),
utils = require('../lib/utils');
Mocha = require('mocha');
require('../lib/extensions');
/**
* After build
......@@ -15,9 +16,9 @@ var fs = require('fs'),
function afterBuild(options) {
var folder = options.debug ? 'Debug' : 'Release';
var target = path.join(__dirname, '..', 'build', folder, 'binding.node');
var install = path.join(__dirname, '..', 'vendor', options.bin, 'binding.node');
var install = path.join(__dirname, '..', 'vendor', process.sassBinaryName, 'binding.node');
mkdir(path.join(__dirname, '..', 'vendor', options.bin), function (err) {
mkdir(path.join(__dirname, '..', 'vendor', process.sassBinaryName), function (err) {
if (err && err.code !== 'EEXIST') {
console.error(err.message);
return;
......@@ -49,9 +50,8 @@ function afterBuild(options) {
*/
function build(options) {
var bin = options.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp';
var proc = spawn(bin, ['rebuild'].concat(options.args), {
customFds: [0, 1, 2]
var proc = spawn(process.execPath, ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args), {
stdio: [0, 1, 2]
});
proc.on('exit', function(code) {
......@@ -92,7 +92,7 @@ function parseArgs(args) {
return false;
} else if (arg.substring(0, 13) === '--target_arch') {
options.arch = arg.substring(14);
} else if (arg === '--debug') {
} else if (arg === '-d' || arg === '--debug') {
options.debug = true;
}
......@@ -110,18 +110,16 @@ function parseArgs(args) {
*/
function testBinary(options) {
options.bin = utils.getBinaryIdentifiableName();
if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options);
}
fs.stat(path.join(__dirname, '..', 'vendor', options.bin, 'binding.node'), function (err) {
fs.stat(path.join(__dirname, '..', 'vendor', process.sassBinaryName, 'binding.node'), function (err) {
if (err) {
return build(options);
}
console.log('`' + options.bin + '` exists; testing');
console.log('`' + process.sassBinaryName + '` exists; testing');
var mocha = new Mocha({
ui: 'bdd',
......
......@@ -2,8 +2,9 @@ var fs = require('fs'),
path = require('path'),
request = require('request'),
mkdirp = require('mkdirp'),
exec = require('shelljs').exec,
utils = require('../lib/utils');
exec = require('shelljs').exec;
require('../lib/extensions');
/**
* Download file, if succeeds save, if not delete
......@@ -77,31 +78,28 @@ function applyProxy(options, cb) {
*/
function exists() {
var name = utils.getBinaryIdentifiableName();
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
fs.exists(path.join(__dirname, '..', 'vendor', process.sassBinaryName), function (exists) {
if (exists) {
return;
}
fetch(name);
fetch();
});
}
/**
* Fetch binaries
*
* @param {String} name
* @api private
*/
function fetch(name) {
function fetch() {
var url = [
'https://raw.githubusercontent.com/sass/node-sass-binaries/v',
require('../package.json').version, '/', name,
require('../package.json').version, '/', process.sassBinaryName,
'/binding.node'
].join('');
var dir = path.join(__dirname, '..', 'vendor', name);
var dir = path.join(__dirname, '..', 'vendor', process.sassBinaryName);
var dest = path.join(dir, 'binding.node');
mkdirp(dir, function(err) {
......
......@@ -194,7 +194,7 @@ void GetSourceMap(sass_context_wrapper* ctx_w, Sass_Context* ctx) {
source_map = NanNew<String>("{}");
}
NanNew(ctx_w->result)->Set(NanNew("sourceMap"), source_map);
NanNew(ctx_w->result)->Set(NanNew("map"), source_map);
}
int GetResult(sass_context_wrapper* ctx_w, Sass_Context* ctx) {
......
......@@ -20,6 +20,45 @@ describe('api', function() {
});
});
it('should compile sass to css with outFile set to absolute url', function(done) {
sass.render({
file: fixture('simple/index.scss'),
sourceMap: true,
outFile: fixture('simple/index-test.css'),
success: function(result) {
assert.equal(JSON.parse(result.map).file, 'index-test.css');
done();
}
});
});
it('should compile sass to css with outFile set to relative url', function(done) {
sass.render({
file: fixture('simple/index.scss'),
sourceMap: true,
outFile: './index-test.css',
success: function(result) {
assert.equal(JSON.parse(result.map).file, 'index-test.css');
done();
}
});
});
it('should compile sass to css with outFile and sourceMap set to relative url', function(done) {
sass.render({
file: fixture('simple/index.scss'),
sourceMap: './deep/nested/index.map',
outFile: './index-test.css',
success: function(result) {
assert.equal(JSON.parse(result.map).file, '../../index-test.css');
done();
}
});
});
it('should compile sass to css with data', function(done) {
var src = read(fixture('simple/index.scss'), 'utf8');
var expected = read(fixture('simple/expected.css'), 'utf8').trim();
......@@ -331,6 +370,39 @@ describe('api', function() {
done();
});
it('should compile sass to css with outFile set to absolute url', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),
sourceMap: true,
outFile: fixture('simple/index-test.css')
});
assert.equal(JSON.parse(result.map).file, 'index-test.css');
done();
});
it('should compile sass to css with outFile set to relative url', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),
sourceMap: true,
outFile: './index-test.css'
});
assert.equal(JSON.parse(result.map).file, 'index-test.css');
done();
});
it('should compile sass to css with outFile and sourceMap set to relative url', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),
sourceMap: './deep/nested/index.map',
outFile: './index-test.css'
});
assert.equal(JSON.parse(result.map).file, '../../index-test.css');
done();
});
it('should compile sass to css with data', function(done) {
var src = read(fixture('simple/index.scss'), 'utf8');
var expected = read(fixture('simple/expected.css'), 'utf8').trim();
......
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