Commit e6a24f1c by Nick Schonning

Chore: Align whitespace to EditorConfig and ESLint

parent 90525f25
#!/usr/bin/env node #!/usr/bin/env node
var Emitter = require('events').EventEmitter, var Emitter = require('events').EventEmitter,
forEach = require('async-foreach').forEach, forEach = require('async-foreach').forEach,
Gaze = require('gaze'), Gaze = require('gaze'),
grapher = require('sass-graph'), grapher = require('sass-graph'),
meow = require('meow'), meow = require('meow'),
util = require('util'), util = require('util'),
path = require('path'), path = require('path'),
glob = require('glob'), glob = require('glob'),
sass = require('../lib'), sass = require('../lib'),
render = require('../lib/render'), render = require('../lib/render'),
stdin = require('get-stdin'), stdin = require('get-stdin'),
fs = require('fs'); fs = require('fs');
/** /**
* Initialize CLI * Initialize CLI
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
var sass = require('./extensions'), var sass = require('./extensions'),
pkg = require('../package.json'); pkg = require('../package.json');
function humanEnvironment() { function humanEnvironment() {
return sass.getHumanEnvironment(sass.getBinaryName()); return sass.getHumanEnvironment(sass.getBinaryName());
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
*/ */
var eol = require('os').EOL, var eol = require('os').EOL,
fs = require('fs'), fs = require('fs'),
pkg = require('../package.json'), pkg = require('../package.json'),
path = require('path'), path = require('path'),
defaultBinaryPath = path.join(__dirname, '..', 'vendor'); defaultBinaryPath = path.join(__dirname, '..', 'vendor');
/** /**
* Get the human readable name of the Platform that is running * Get the human readable name of the Platform that is running
...@@ -82,10 +82,10 @@ function getHumanNodeVersion(abi) { ...@@ -82,10 +82,10 @@ function getHumanNodeVersion(abi) {
*/ */
function getHumanEnvironment(env) { function getHumanEnvironment(env) {
var binding = env.replace(/_binding\.node$/, ''), var binding = env.replace(/_binding\.node$/, ''),
parts = binding.split('-'), parts = binding.split('-'),
platform = getHumanPlatform(parts[0]), platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]), arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]); runtime = getHumanNodeVersion(parts[2]);
if (parts.length !== 3) { if (parts.length !== 3) {
return 'Unknown environment (' + binding + ')'; return 'Unknown environment (' + binding + ')';
...@@ -148,7 +148,7 @@ function isSupportedEnvironment(platform, arch, abi) { ...@@ -148,7 +148,7 @@ function isSupportedEnvironment(platform, arch, abi) {
function getArgument(name, args) { function getArgument(name, args) {
var flags = args || process.argv.slice(2), var flags = args || process.argv.slice(2),
index = flags.lastIndexOf(name); index = flags.lastIndexOf(name);
if (index === -1 || index + 1 >= flags.length) { if (index === -1 || index + 1 >= flags.length) {
return null; return null;
...@@ -223,7 +223,7 @@ function getBinaryUrl() { ...@@ -223,7 +223,7 @@ function getBinaryUrl() {
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) || (pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download'; 'https://github.com/sass/node-sass/releases/download';
return [site, 'v' + pkg.version, getBinaryName()].join('/'); return [site, 'v' + pkg.version, getBinaryName()].join('/');
} }
/** /**
...@@ -277,8 +277,8 @@ function hasBinary(binaryPath) { ...@@ -277,8 +277,8 @@ function hasBinary(binaryPath) {
function getVersionInfo(binding) { function getVersionInfo(binding) {
return [ return [
['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'), ['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'), ['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol); ].join(eol);
} }
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
*/ */
var path = require('path'), var path = require('path'),
util = require('util'), util = require('util'),
clonedeep = require('lodash.clonedeep'), clonedeep = require('lodash.clonedeep'),
errors = require('./errors'), errors = require('./errors'),
sass = require('./extensions'); sass = require('./extensions');
if (!sass.hasBinary(sass.getBinaryPath())) { if (!sass.hasBinary(sass.getBinaryPath())) {
if (!sass.isSupportedEnvironment()) { if (!sass.isSupportedEnvironment()) {
...@@ -239,8 +239,8 @@ function normalizeFunctionSignature(signature, callback) { ...@@ -239,8 +239,8 @@ function normalizeFunctionSignature(signature, callback) {
signature: signature + '(...)', signature: signature + '(...)',
callback: function() { callback: function() {
var args = Array.prototype.slice.call(arguments), var args = Array.prototype.slice.call(arguments),
list = args.shift(), list = args.shift(),
i; i;
for (i = list.getLength() - 1; i >= 0; i--) { for (i = list.getLength() - 1; i >= 0; i--) {
args.unshift(list.getValue(i)); args.unshift(list.getValue(i));
...@@ -333,7 +333,7 @@ module.exports.render = function(opts, cb) { ...@@ -333,7 +333,7 @@ module.exports.render = function(opts, cb) {
options.functions[cb.signature] = function() { options.functions[cb.signature] = function() {
var args = Array.prototype.slice.call(arguments), var args = Array.prototype.slice.call(arguments),
bridge = args.pop(); bridge = args.pop();
function done(data) { function done(data) {
bridge.success(data); bridge.success(data);
...@@ -403,11 +403,11 @@ module.exports.renderSync = function(opts) { ...@@ -403,11 +403,11 @@ module.exports.renderSync = function(opts) {
var status; var status;
if (options.data) { if (options.data) {
status = binding.renderSync(options); status = binding.renderSync(options);
} else if (options.file) { } else if (options.file) {
status = binding.renderFileSync(options); status = binding.renderFileSync(options);
} else { } else {
throw new Error('No input specified: provide a file name or a source string to process'); throw new Error('No input specified: provide a file name or a source string to process');
} }
var result = options.result; var result = options.result;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
*/ */
var chalk = require('chalk'), var chalk = require('chalk'),
fs = require('fs'), fs = require('fs'),
mkdirp = require('mkdirp'), mkdirp = require('mkdirp'),
path = require('path'), path = require('path'),
sass = require('./'); sass = require('./');
/** /**
* Render * Render
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
*/ */
var eol = require('os').EOL, var eol = require('os').EOL,
pkg = require('../package.json'), pkg = require('../package.json'),
fs = require('fs'), fs = require('fs'),
mkdir = require('mkdirp'), mkdir = require('mkdirp'),
path = require('path'), path = require('path'),
spawn = require('cross-spawn'), spawn = require('cross-spawn'),
sass = require('../lib/extensions'); sass = require('../lib/extensions');
/** /**
* After build * After build
......
...@@ -3,52 +3,52 @@ ...@@ -3,52 +3,52 @@
*/ */
var Mocha = require('mocha'), var Mocha = require('mocha'),
fs = require('fs'), fs = require('fs'),
path = require('path'), path = require('path'),
mkdirp = require('mkdirp'), mkdirp = require('mkdirp'),
coveralls = require('coveralls'), coveralls = require('coveralls'),
Instrumenter = require('istanbul').Instrumenter, Instrumenter = require('istanbul').Instrumenter,
Report = require('istanbul').Report, Report = require('istanbul').Report,
Collector = new require('istanbul').Collector, Collector = new require('istanbul').Collector,
sourcefiles = ['index.js', 'extensions.js', 'render.js', 'errors.js'], sourcefiles = ['index.js', 'extensions.js', 'render.js', 'errors.js'],
summary= Report.create('text-summary'), summary= Report.create('text-summary'),
lcov = Report.create('lcovonly', { dir: path.join('coverage') }), lcov = Report.create('lcovonly', { dir: path.join('coverage') }),
html = Report.create('html', { dir: path.join('coverage', 'html') }); html = Report.create('html', { dir: path.join('coverage', 'html') });
function coverage() { function coverage() {
var mocha = new Mocha(); var mocha = new Mocha();
var rep = function(runner) { var rep = function(runner) {
runner.on('end', function(){ runner.on('end', function(){
var cov = global.__coverage__, var cov = global.__coverage__,
collector = new Collector(); collector = new Collector();
if (cov) { if (cov) {
mkdirp(path.join('coverage', 'html'), function(err) { mkdirp(path.join('coverage', 'html'), function(err) {
if (err) { throw err; } if (err) { throw err; }
collector.add(cov); collector.add(cov);
summary.writeReport(collector, true); summary.writeReport(collector, true);
html.writeReport(collector, true); html.writeReport(collector, true);
lcov.on('done', function() { lcov.on('done', function() {
fs.readFile(path.join('coverage', 'lcov.info'), function(err, data) { fs.readFile(path.join('coverage', 'lcov.info'), function(err, data) {
if (err) { console.error(err); } if (err) { console.error(err); }
coveralls.handleInput(data.toString(), coveralls.handleInput(data.toString(),
function (err) { if (err) { console.error(err); } }); function (err) { if (err) { console.error(err); } });
});
}); });
lcov.writeReport(collector, true);
}); });
} else { lcov.writeReport(collector, true);
console.warn('No coverage'); });
} } else {
}); console.warn('No coverage');
}; }
var instrumenter = new Instrumenter(); });
var instrumentedfiles = []; };
var processfile = function(source) { var instrumenter = new Instrumenter();
fs.readFile(path.join('lib', source), function(err, data) { var instrumentedfiles = [];
if (err) { throw err; } var processfile = function(source) {
mkdirp('lib-cov', function(err) { fs.readFile(path.join('lib', source), function(err, data) {
if (err) { throw err; } if (err) { throw err; }
fs.writeFile(path.join('lib-cov', source), mkdirp('lib-cov', function(err) {
if (err) { throw err; }
fs.writeFile(path.join('lib-cov', source),
instrumenter.instrumentSync(data.toString(), instrumenter.instrumentSync(data.toString(),
path.join('lib', source)), path.join('lib', source)),
function(err) { function(err) {
...@@ -72,12 +72,12 @@ function coverage() { ...@@ -72,12 +72,12 @@ function coverage() {
}); });
} }
}); });
}); });
}); });
}; };
for (var i in sourcefiles) { for (var i in sourcefiles) {
processfile(sourcefiles[i]); processfile(sourcefiles[i]);
} }
} }
/** /**
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
*/ */
var fs = require('fs'), var fs = require('fs'),
eol = require('os').EOL, eol = require('os').EOL,
mkdir = require('mkdirp'), mkdir = require('mkdirp'),
path = require('path'), path = require('path'),
sass = require('../lib/extensions'), sass = require('../lib/extensions'),
request = require('request'), request = require('request'),
pkg = require('../package.json'); pkg = require('../package.json');
/** /**
* Download file, if succeeds save, if not delete * Download file, if succeeds save, if not delete
...@@ -47,15 +47,15 @@ function download(url, dest, cb) { ...@@ -47,15 +47,15 @@ function download(url, dest, cb) {
if (err) { if (err) {
reportError(err); reportError(err);
} else if (!successful(response)) { } else if (!successful(response)) {
reportError(['HTTP error', response.statusCode, response.statusMessage].join(' ')); reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
} else { } else {
cb(); cb();
} }
}) })
.on('response', function(response) { .on('response', function(response) {
if (successful(response)) { if (successful(response)) {
response.pipe(fs.createWriteStream(dest)); response.pipe(fs.createWriteStream(dest));
} }
}); });
} catch (err) { } catch (err) {
cb(err); cb(err);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
var path = require('path'), var path = require('path'),
rimraf = require('rimraf'); rimraf = require('rimraf');
function prepublish() { function prepublish() {
var vendorPath = path.resolve(__dirname, '..', 'vendor'); var vendorPath = path.resolve(__dirname, '..', 'vendor');
......
var assert = require('assert'), var assert = require('assert'),
fs = require('fs'), fs = require('fs'),
path = require('path'), path = require('path'),
read = fs.readFileSync, read = fs.readFileSync,
sassPath = process.env.NODESASS_COV sassPath = process.env.NODESASS_COV
? require.resolve('../lib-cov') ? require.resolve('../lib-cov')
: require.resolve('../lib'), : require.resolve('../lib'),
sass = require(sassPath), sass = require(sassPath),
fixture = path.join.bind(null, __dirname, 'fixtures'), fixture = path.join.bind(null, __dirname, 'fixtures'),
resolveFixture = path.resolve.bind(null, __dirname, 'fixtures'); resolveFixture = path.resolve.bind(null, __dirname, 'fixtures');
describe('api', function() { describe('api', function() {
...@@ -233,7 +233,7 @@ describe('api', function() { ...@@ -233,7 +233,7 @@ describe('api', function() {
contents: '@import "b"' contents: '@import "b"'
}); });
} else { } else {
console.log(prev); console.log(prev);
assert.equal(prev, '/Users/me/sass/lib/a.scss'); assert.equal(prev, '/Users/me/sass/lib/a.scss');
done({ done({
file: '/Users/me/sass/lib/b.scss', file: '/Users/me/sass/lib/b.scss',
...@@ -1321,7 +1321,7 @@ describe('api', function() { ...@@ -1321,7 +1321,7 @@ describe('api', function() {
it('should throw error for bad input', function(done) { it('should throw error for bad input', function(done) {
assert.throws(function() { assert.throws(function() {
sass.renderSync('somestring'); sass.renderSync('somestring');
}); });
assert.throws(function() { assert.throws(function() {
sass.renderSync({ data: '#navbar width 80%;' }); sass.renderSync({ data: '#navbar width 80%;' });
...@@ -1555,7 +1555,7 @@ describe('api', function() { ...@@ -1555,7 +1555,7 @@ describe('api', function() {
functions: { functions: {
'headings($from: 0, $to: 6)': function(from, to) { 'headings($from: 0, $to: 6)': function(from, to) {
var i, f = from.getValue(), t = to.getValue(), var i, f = from.getValue(), t = to.getValue(),
list = new sass.types.List(t - f + 1); list = new sass.types.List(t - f + 1);
for (i = f; i <= t; i++) { for (i = f; i <= t; i++) {
list.setValue(i - f, new sass.types.String('h' + i)); list.setValue(i - f, new sass.types.String('h' + i));
...@@ -1766,7 +1766,7 @@ describe('api', function() { ...@@ -1766,7 +1766,7 @@ describe('api', function() {
describe('.info', function() { describe('.info', function() {
var package = require('../package.json'), var package = require('../package.json'),
info = sass.info; info = sass.info;
it('should return a correct version info', function(done) { it('should return a correct version info', function(done) {
assert(info.indexOf(package.version) > 0); assert(info.indexOf(package.version) > 0);
......
var assert = require('assert'), var assert = require('assert'),
fs = require('fs'), fs = require('fs'),
path = require('path'), path = require('path'),
read = require('fs').readFileSync, read = require('fs').readFileSync,
glob = require('glob'), glob = require('glob'),
rimraf = require('rimraf'), rimraf = require('rimraf'),
stream = require('stream'), stream = require('stream'),
spawn = require('cross-spawn'), spawn = require('cross-spawn'),
cli = path.join(__dirname, '..', 'bin', 'node-sass'), cli = path.join(__dirname, '..', 'bin', 'node-sass'),
fixture = path.join.bind(null, __dirname, 'fixtures'), fixture = path.join.bind(null, __dirname, 'fixtures'),
LIBSASS_VERSION = null; LIBSASS_VERSION = null;
describe('cli', function() { describe('cli', function() {
before(function(done) { before(function(done) {
var bin = spawn(cli, ['-v']); var bin = spawn(cli, ['-v']);
bin.stdout.setEncoding('utf8'); bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) { bin.stdout.once('data', function(data) {
LIBSASS_VERSION = data.trim().split(['\n']) LIBSASS_VERSION = data.trim().split(['\n'])
.filter(function(a) { return a.substr(0,7) === 'libsass'; })[0] .filter(function(a) { return a.substr(0,7) === 'libsass'; })[0]
.split('\t')[1]; .split('\t')[1];
done(); done();
}); });
}); });
describe('node-sass < in.scss', function() { describe('node-sass < in.scss', function() {
...@@ -472,23 +472,23 @@ describe('cli', function() { ...@@ -472,23 +472,23 @@ describe('cli', function() {
}); });
it('should compile with the --source-map-embed option and no outfile', function(done) { it('should compile with the --source-map-embed option and no outfile', function(done) {
var src = fixture('source-map-embed/index.scss'); var src = fixture('source-map-embed/index.scss');
var expectedCss = read(fixture('source-map-embed/expected.css'), 'utf8').trim().replace(/\r\n/g, '\n'); var expectedCss = read(fixture('source-map-embed/expected.css'), 'utf8').trim().replace(/\r\n/g, '\n');
var result = ''; var result = '';
var bin = spawn(cli, [ var bin = spawn(cli, [
src, src,
'--source-map-embed', '--source-map-embed',
'--source-map', 'true' '--source-map', 'true'
]); ]);
bin.stdout.on('data', function(data) { bin.stdout.on('data', function(data) {
result += data; result += data;
}); });
bin.once('close', function() { bin.once('close', function() {
assert.equal(result.trim().replace(/\r\n/g, '\n'), expectedCss); assert.equal(result.trim().replace(/\r\n/g, '\n'), expectedCss);
done(); done();
}); });
}); });
}); });
......
var assert = require('assert'), var assert = require('assert'),
path = require('path'), path = require('path'),
errors = require('../lib/errors'); errors = require('../lib/errors');
describe('binary errors', function() { describe('binary errors', function() {
......
process.env.NODESASS_COV ? require('../lib-cov') : require('../lib'); process.env.NODESASS_COV ? require('../lib-cov') : require('../lib');
var assert = require('assert'), var assert = require('assert'),
sass = require('../lib/extensions'), sass = require('../lib/extensions'),
binding = require(sass.getBinaryPath()); binding = require(sass.getBinaryPath());
describe('lowlevel', function() { describe('lowlevel', function() {
it('fail with options not an object', function(done) { it('fail with options not an object', function(done) {
...@@ -194,8 +194,8 @@ describe('lowlevel', function() { ...@@ -194,8 +194,8 @@ describe('lowlevel', function() {
linefeed: '\n', linefeed: '\n',
result: { stats: {} } }; result: { stats: {} } };
binding.renderSync(options); binding.renderSync(options);
assert(options.result.css); assert(options.result.css);
done(); done();
}); });
...@@ -213,8 +213,8 @@ describe('lowlevel', function() { ...@@ -213,8 +213,8 @@ describe('lowlevel', function() {
linefeed: '\n', linefeed: '\n',
result: { stats: {} } }; result: { stats: {} } };
binding.renderSync(options); binding.renderSync(options);
assert(/empty source string/.test(options.result.error), assert(/empty source string/.test(options.result.error),
'Should fail with error message "Data context created with empty source string"'); 'Should fail with error message "Data context created with empty source string"');
done(); done();
}); });
...@@ -234,8 +234,8 @@ describe('lowlevel', function() { ...@@ -234,8 +234,8 @@ describe('lowlevel', function() {
linefeed: '\n', linefeed: '\n',
result: { stats: {} } }; result: { stats: {} } };
binding.renderFileSync(options); binding.renderFileSync(options);
assert(/empty input path/.test(options.result.error), assert(/empty input path/.test(options.result.error),
'Should fail with error message "File context created with empty input path"'); 'Should fail with error message "File context created with empty input path"');
done(); done();
}); });
......
var assert = require('assert'), var assert = require('assert'),
extensionsPath = process.env.NODESASS_COV extensionsPath = process.env.NODESASS_COV
? require.resolve('../lib-cov/extensions') ? require.resolve('../lib-cov/extensions')
: require.resolve('../lib/extensions'); : require.resolve('../lib/extensions');
describe('runtime parameters', function() { describe('runtime parameters', function() {
var packagePath = require.resolve('../package'), var packagePath = require.resolve('../package'),
// Let's use JSON to fake a deep copy // Let's use JSON to fake a deep copy
savedArgv = JSON.stringify(process.argv), savedArgv = JSON.stringify(process.argv),
savedEnv = JSON.stringify(process.env); savedEnv = JSON.stringify(process.env);
beforeEach(function() {
require(packagePath);
delete require.cache[extensionsPath];
});
afterEach(function() {
delete require.cache[packagePath];
delete require.cache[extensionsPath];
process.argv = JSON.parse(savedArgv);
process.env = JSON.parse(savedEnv);
require(packagePath);
});
describe('configuration precedence should be respected', function() {
describe('SASS_BINARY_NAME', function() {
beforeEach(function() {
process.argv.push('--sass-binary-name', 'aaa');
process.env.SASS_BINARY_NAME = 'bbb';
process.env.npm_config_sass_binary_name = 'ccc';
require.cache[packagePath].exports.nodeSassConfig = { binaryName: 'ddd' };
});
it('command line argument', function() {
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'aaa_binding.node');
});
beforeEach(function() { it('environment variable', function() {
require(packagePath); process.argv = [];
delete require.cache[extensionsPath]; var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'bbb_binding.node');
});
it('npm config variable', function() {
process.argv = [];
process.env.SASS_BINARY_NAME = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'ccc_binding.node');
});
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_NAME = null;
process.env.npm_config_sass_binary_name = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'ddd_binding.node');
});
}); });
afterEach(function() { describe('SASS_BINARY_SITE', function() {
delete require.cache[packagePath]; beforeEach(function() {
delete require.cache[extensionsPath]; process.argv.push('--sass-binary-site', 'http://aaa.example.com:9999');
process.argv = JSON.parse(savedArgv); process.env.SASS_BINARY_SITE = 'http://bbb.example.com:8888';
process.env = JSON.parse(savedEnv); process.env.npm_config_sass_binary_site = 'http://ccc.example.com:7777';
require(packagePath); require.cache[packagePath].exports.nodeSassConfig = { binarySite: 'http://ddd.example.com:6666' };
});
it('command line argument', function() {
var sass = require(extensionsPath);
var URL = 'http://aaa.example.com:9999';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('environment variable', function() {
process.argv = [];
var sass = require(extensionsPath);
var URL = 'http://bbb.example.com:8888';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('npm config variable', function() {
process.argv = [];
process.env.SASS_BINARY_SITE = null;
var sass = require(extensionsPath);
var URL = 'http://ccc.example.com:7777';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_SITE = null;
process.env.npm_config_sass_binary_site = null;
var sass = require(extensionsPath);
var URL = 'http://ddd.example.com:6666';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
}); });
describe('configuration precedence should be respected', function() { describe('SASS_BINARY_PATH', function() {
beforeEach(function() {
describe('SASS_BINARY_NAME', function() { process.argv.push('--sass-binary-path', 'aaa_binding.node');
beforeEach(function() { process.env.SASS_BINARY_PATH = 'bbb_binding.node';
process.argv.push('--sass-binary-name', 'aaa'); process.env.npm_config_sass_binary_path = 'ccc_binding.node';
process.env.SASS_BINARY_NAME = 'bbb'; require.cache[packagePath].exports.nodeSassConfig = { binaryPath: 'ddd_binding.node' };
process.env.npm_config_sass_binary_name = 'ccc'; });
require.cache[packagePath].exports.nodeSassConfig = { binaryName: 'ddd' };
}); it('command line argument', function() {
var sass = require(extensionsPath);
it('command line argument', function() { assert.equal(sass.getBinaryPath(), 'aaa_binding.node');
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'aaa_binding.node');
});
it('environment variable', function() {
process.argv = [];
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'bbb_binding.node');
});
it('npm config variable', function() {
process.argv = [];
process.env.SASS_BINARY_NAME = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'ccc_binding.node');
});
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_NAME = null;
process.env.npm_config_sass_binary_name = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryName(), 'ddd_binding.node');
});
}); });
describe('SASS_BINARY_SITE', function() { it('environment variable', function() {
beforeEach(function() { process.argv = [];
process.argv.push('--sass-binary-site', 'http://aaa.example.com:9999'); var sass = require(extensionsPath);
process.env.SASS_BINARY_SITE = 'http://bbb.example.com:8888'; assert.equal(sass.getBinaryPath(), 'bbb_binding.node');
process.env.npm_config_sass_binary_site = 'http://ccc.example.com:7777';
require.cache[packagePath].exports.nodeSassConfig = { binarySite: 'http://ddd.example.com:6666' };
});
it('command line argument', function() {
var sass = require(extensionsPath);
var URL = 'http://aaa.example.com:9999';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('environment variable', function() {
process.argv = [];
var sass = require(extensionsPath);
var URL = 'http://bbb.example.com:8888';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('npm config variable', function() {
process.argv = [];
process.env.SASS_BINARY_SITE = null;
var sass = require(extensionsPath);
var URL = 'http://ccc.example.com:7777';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_SITE = null;
process.env.npm_config_sass_binary_site = null;
var sass = require(extensionsPath);
var URL = 'http://ddd.example.com:6666';
assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
});
}); });
describe('SASS_BINARY_PATH', function() { it('npm config variable', function() {
beforeEach(function() { process.argv = [];
process.argv.push('--sass-binary-path', 'aaa_binding.node'); process.env.SASS_BINARY_PATH = null;
process.env.SASS_BINARY_PATH = 'bbb_binding.node'; var sass = require(extensionsPath);
process.env.npm_config_sass_binary_path = 'ccc_binding.node'; assert.equal(sass.getBinaryPath(), 'ccc_binding.node');
require.cache[packagePath].exports.nodeSassConfig = { binaryPath: 'ddd_binding.node' };
});
it('command line argument', function() {
var sass = require(extensionsPath);
assert.equal(sass.getBinaryPath(), 'aaa_binding.node');
});
it('environment variable', function() {
process.argv = [];
var sass = require(extensionsPath);
assert.equal(sass.getBinaryPath(), 'bbb_binding.node');
});
it('npm config variable', function() {
process.argv = [];
process.env.SASS_BINARY_PATH = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryPath(), 'ccc_binding.node');
});
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_PATH = null;
process.env.npm_config_sass_binary_path = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryPath(), 'ddd_binding.node');
});
}); });
it('package.json', function() {
process.argv = [];
process.env.SASS_BINARY_PATH = null;
process.env.npm_config_sass_binary_path = null;
var sass = require(extensionsPath);
assert.equal(sass.getBinaryPath(), 'ddd_binding.node');
});
}); });
});
}); });
// describe('library detection', function() { // describe('library detection', function() {
......
var assert = require('assert'), var assert = require('assert'),
fs = require('fs'), fs = require('fs'),
exists = fs.existsSync, exists = fs.existsSync,
path = require('path'), path = require('path'),
read = fs.readFileSync, read = fs.readFileSync,
sass = process.env.NODESASS_COV sass = process.env.NODESASS_COV
? require('../lib-cov') ? require('../lib-cov')
: require('../lib'), : require('../lib'),
util = require('./util'); util = require('./util');
describe('spec', function() { describe('spec', function() {
this.timeout(0); this.timeout(0);
......
var fs = require('fs'), var fs = require('fs'),
join = require('path').join, join = require('path').join,
spec = join(__dirname, '..', 'fixtures', 'spec', 'spec'); spec = join(__dirname, '..', 'fixtures', 'spec', 'spec');
/** /**
* Normalize CSS * Normalize CSS
......
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