Socket
Socket
Sign inDemoInstall

node-sass

Package Overview
Dependencies
Maintainers
3
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-sass - npm Package Compare versions

Comparing version 0.8.6 to 0.9.0

libsass/.gitmodules

2

build.js

@@ -43,3 +43,3 @@ #!/usr/bin/env node

mocha.addFile(path.resolve(__dirname, "test", "test.js"));
mocha.addFile(path.resolve(__dirname, 'test', 'test.js'));

@@ -46,0 +46,0 @@ mocha.run(function (done) {

@@ -47,3 +47,3 @@ var sass = require('../sass'),

// Accept src/dest dir
if ('string' == typeof options) {
if ('string' === typeof options) {
options = { src: options };

@@ -76,3 +76,3 @@ }

return function sass(req, res, next){
if ('GET' != req.method && 'HEAD' != req.method) { return next(); }
if ('GET' !== req.method && 'HEAD' !== req.method) { return next(); }
var path = url.parse(req.url).pathname;

@@ -102,3 +102,3 @@ if (options.prefix && 0 === path.indexOf(options.prefix)) {

var error = function(err) {
next('ENOENT' == err.code
next('ENOENT' === err.code
? null

@@ -145,3 +145,3 @@ : err);

if (err) {
if ('ENOENT' == err.code) {
if ('ENOENT' === err.code) {
if (debug) { log('not found', cssPath); }

@@ -148,0 +148,0 @@ compile();

@@ -5,3 +5,3 @@ {

"description": "wrapper around libsass",
"version": "0.8.6",
"version": "0.9.0",
"homepage": "https://github.com/andrew/node-sass",

@@ -29,6 +29,6 @@ "keywords": [

"install": "node build.js",
"test": "mocha test",
"coverage": "bash scripts/coverage.sh",
"pretest": "jshint .",
"prepublish": "bash scripts/prepublish.sh"
"test": "node scripts/test",
"coverage": "node scripts/coverage",
"pretest": "node scripts/lint",
"prepublish": "node scripts/prepublish"
},

@@ -43,16 +43,17 @@ "bin": {

"dependencies": {
"mkdirp": "0.3.x",
"optimist": "0.6.x",
"node-watch": "0.3.x",
"chalk": "~0.4.0",
"nan": "~0.8.0",
"mocha": "1.18.x",
"sinon": "^1.9.1"
"mkdirp": "~0.3.5",
"mocha": "~1.18.2",
"nan": "~1.0.0",
"node-watch": "~0.3.4",
"optimist": "~0.6.1",
"shelljs": "~0.2.6",
"sinon": "~1.9.1"
},
"devDependencies": {
"jshint": "~2.4.4",
"coveralls": "~2.10.0",
"mocha-lcov-reporter": "0.0.1",
"jscoverage": "~0.3.8"
"jscoverage": "~0.3.8",
"jshint": "~2.5.0",
"mocha-lcov-reporter": "~0.0.1"
}
}

@@ -81,2 +81,18 @@ # node-sass

#### stats
`stats` is an empty `Object` that will be filled with stats from the compilation:
```javascript
{
entry: "path/to/entry.scss", // or just "data" if the source was not a file
start: 10000000, // Date.now() before the compilation
end: 10000001, // Date.now() after the compilation
duration: 1, // end - start
includedFiles: [ ... ], // absolute paths to all related scss files
sourceMap: "..." // the source map string or null
}
```
`includedFiles` isn't sorted in any meaningful way, it's just a list of all imported scss files including the entry.
### renderFile()

@@ -105,6 +121,8 @@

var sass = require('node-sass');
var stats = {};
sass.render({
data: 'body{background:blue; a{color:black;}}',
success: function(css){
console.log(css)
success: function(css) {
console.log(css);
console.log(stats);
},

@@ -115,3 +133,4 @@ error: function(error) {

includePaths: [ 'lib/', 'mod/' ],
outputStyle: 'compressed'
outputStyle: 'compressed',
stats: stats
});

@@ -121,4 +140,6 @@ // OR

data: 'body{background:blue; a{color:black;}}',
outputStyle: 'compressed'
outputStyle: 'compressed',
stats: stats
}));
console.log(stats);
```

@@ -165,2 +186,6 @@

## Metalsmith plugin
[@stevenschobert](https://github.com/stevenschobert/) has created a gulp sass plugin based on node-sass: <https://github.com/stevenschobert/metalsmith-sass>
## Meteor plugin

@@ -167,0 +192,0 @@

@@ -6,10 +6,10 @@ var path = require('path');

var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0];
var candidates = [
[__dirname, 'build', 'Release', 'obj.target', 'binding.node'],
[__dirname, 'bin', process.platform + '-' + process.arch + '-' + v8, 'binding.node'],
[__dirname, 'bin', process.platform + '-' + process.arch + '-' + v8, 'binding.node']
];
var candidate;
for (var i = 0, l = candidates.length; i < l; i++) {
var candidate = path.join.apply(path.join, candidates[i]);
candidate = path.join.apply(path.join, candidates[i]);

@@ -27,44 +27,76 @@ if (fs.existsSync(candidate)) {

var SASS_OUTPUT_STYLE = {
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
var SASS_SOURCE_COMMENTS = {
none: 0,
// This is called default in libsass, but is a reserved keyword here
normal: 1,
map: 2
};
none: 0,
normal: 1,
'default': 1,
map: 2
};
var prepareOptions = function(options) {
var paths, imagePath, style, comments;
options = typeof options !== 'object' ? {} : options;
var sourceComments = options.source_comments || options.sourceComments;
var prepareOptions = function (options) {
var success;
var error;
var stats;
var sourceComments;
options = options || {};
success = options.success;
error = options.error;
stats = options.stats || {};
sourceComments = options.source_comments || options.sourceComments;
if (options.sourceMap && !sourceComments) {
sourceComments = 'map';
}
paths = options.include_paths || options.includePaths || [];
imagePath = options.image_path || options.imagePath || '';
style = SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0;
comments = SASS_SOURCE_COMMENTS[sourceComments] || 0;
prepareStats(options, stats);
return {
paths: paths,
imagePath: imagePath,
style: style,
comments: comments
file: options.file || null,
outFile: options.outFile || null,
data: options.data || null,
paths: (options.include_paths || options.includePaths || []).join(path.delimiter),
imagePath: options.image_path || options.imagePath || '',
style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0,
comments: SASS_SOURCE_COMMENTS[sourceComments] || 0,
stats: stats,
sourceMap: options.sourceMap,
success: function onSuccess(css, sourceMap) {
finishStats(stats, sourceMap);
success && success(css, sourceMap);
},
error: function onError(err, errStatus) {
error && error(err, errStatus);
}
};
};
var prepareStats = function (options, stats) {
stats.entry = options.file || 'data';
stats.start = Date.now();
return stats;
};
var finishStats = function (stats, sourceMap) {
stats.end = Date.now();
stats.duration = stats.end - stats.start;
stats.sourceMap = sourceMap;
return stats;
};
var deprecatedRender = function(css, callback, options) {
options = prepareOptions(options);
var errCallback = function(err) {
callback(err);
};
var oldCallback = function(css) {
// providing the deprecated single callback signature
options.error = callback;
options.success = function(css) {
callback(null, css);
};
return binding.render(css, options.imagePath, oldCallback, errCallback, options.paths.join(path.delimiter), options.style, options.comments);
options.data = css;
binding.render(options);
};

@@ -74,8 +106,7 @@

options = prepareOptions(options);
return binding.renderSync(css, options.imagePath, options.paths.join(path.delimiter), options.style, options.comments);
options.data = css;
return binding.renderSync(options);
};
exports.render = function(options) {
var newOptions;
if (typeof arguments[0] === 'string') {

@@ -85,15 +116,8 @@ return deprecatedRender.apply(this, arguments);

newOptions = prepareOptions(options);
options.error = options.error || function(){};
if (options.file !== undefined && options.file !== null) {
return binding.renderFile(options.file, newOptions.imagePath, options.success, options.error, newOptions.paths.join(path.delimiter), newOptions.style, newOptions.comments, options.sourceMap);
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return binding.render(options.data, newOptions.imagePath, options.success, options.error, newOptions.paths.join(path.delimiter), newOptions.style);
options = prepareOptions(options);
options.file? binding.renderFile(options) : binding.render(options);
};
exports.renderSync = function(options) {
var newOptions;
var output;

@@ -104,10 +128,7 @@ if (typeof arguments[0] === 'string') {

newOptions = prepareOptions(options);
options = prepareOptions(options);
output = options.file? binding.renderFileSync(options) : binding.renderSync(options);
finishStats(options.stats);
if (options.file !== undefined && options.file !== null) {
return binding.renderFileSync(options.file, newOptions.imagePath, newOptions.paths.join(path.delimiter), newOptions.style, newOptions.comments);
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return binding.renderSync(options.data, newOptions.imagePath, newOptions.paths.join(path.delimiter), newOptions.style);
return output;
};

@@ -128,22 +149,22 @@

exports.renderFile = function(options) {
var newOptions = {};
for (var i in options) {
if (options.hasOwnProperty(i)) {
newOptions[i] = options[i];
}
}
var success;
options = prepareOptions(options);
success = options.success;
if (options.sourceMap === true) {
newOptions.sourceMap = path.basename(options.outFile) + '.map';
options.sourceMap = path.basename(options.outFile) + '.map';
}
newOptions.success = function(css, sourceMap) {
options.success = function(css, sourceMap) {
fs.writeFile(options.outFile, css, function(err) {
var dir, sourceMapFile;
if (err) {
return error(err);
return options.error(err);
}
if (options.sourceMap) {
var dir = path.dirname(options.outFile);
var sourceMapFile = path.resolve(dir, newOptions.sourceMap);
dir = path.dirname(options.outFile);
sourceMapFile = path.resolve(dir, options.sourceMap);
fs.writeFile(sourceMapFile, sourceMap, function(err) {
if (err) {
return error(err);
return options.error(err);
}

@@ -158,15 +179,5 @@ success(options.outFile, sourceMapFile);

};
function error(err) {
if (options.error) {
options.error(err);
}
}
function success(css, sourceMap) {
if (options.success) {
options.success(css, sourceMap);
}
}
exports.render(newOptions);
exports.render(options);
};
exports.middleware = require('./lib/middleware');

@@ -42,3 +42,4 @@ var path = require('path'),

cwd: __dirname
}, function() {
}, function(err) {
assert.equal(err, null);

@@ -57,3 +58,4 @@ fs.exists(resultPath, function(exists) {

cwd: __dirname
}, function() {
}, function(err) {
assert.equal(err, null);

@@ -60,0 +62,0 @@ fs.exists(resultPath, function(exists) {

@@ -1,2 +0,1 @@

/*jshint multistr:true */
var sass = require('../sass');

@@ -23,4 +22,4 @@ var assert = require('assert');

describe("compile file with source comments", function() {
it("should compile with render and comment outputs", function(done) {
describe('compile file with source comments', function() {
it('should compile with render and comment outputs', function(done) {
sass.render({

@@ -27,0 +26,0 @@ file: sampleFilename,

@@ -1,2 +0,1 @@

/*jshint multistr:true */
var sass = require('../sass');

@@ -7,4 +6,4 @@ var assert = require('assert');

describe("compile source maps", function() {
it("should compile file with source map URL", function(done) {
describe('compile source maps', function() {
it('should compile file with source map URL', function(done) {
var mapFileName = 'sample.css.map';

@@ -11,0 +10,0 @@ sass.render({

@@ -1,3 +0,1 @@

/* global beforeEach, afterEach */
/*jshint multistr:true */
var sass = process.env.NODESASS_COVERAGE ? require('../sass-coverage') : require('../sass');

@@ -10,37 +8,9 @@ var assert = require('assert');

var sampleFilename = path.resolve(__dirname, 'sample.scss');
var sample = require('./sample.js');
var scssStr = '#navbar {\
width: 80%;\
height: 23px; }\
#navbar ul {\
list-style-type: none; }\
#navbar li {\
float: left;\
a {\
font-weight: bold; }}\
@mixin keyAnimation($name, $attr, $value) {\
@-webkit-keyframes #{$name} {\
0% { #{$attr}: $value; }\
}\
}';
// Note that the bad
var badInput = '#navbar \n\
width: 80%';
var expectedRender = '#navbar {\n\
width: 80%;\n\
height: 23px; }\n\
\n\
#navbar ul {\n\
list-style-type: none; }\n\
\n\
#navbar li {\n\
float: left; }\n\
#navbar li a {\n\
font-weight: bold; }\n';
describe("DEPRECATED: compile scss", function() {
it("should compile with render", function(done) {
sass.render(scssStr, function(err) {
describe('DEPRECATED: compile scss', function() {
it('should compile with render', function(done) {
sass.render(sample.input, function(err) {
done(err);

@@ -50,10 +20,10 @@ });

it("should compile with renderSync", function(done) {
done(assert.ok(sass.renderSync(scssStr)));
it('should compile with renderSync', function(done) {
done(assert.ok(sass.renderSync(sample.input)));
});
it("should match compiled string with render", function(done) {
sass.render(scssStr, function(err, css) {
it('should match compiled string with render', function(done) {
sass.render(sample.input, function(err, css) {
if (!err) {
done(assert.equal(css, expectedRender));
done(assert.equal(css, sample.expectedRender));
} else {

@@ -65,9 +35,9 @@ done(err);

it("should match compiled string with renderSync", function(done) {
done(assert.equal(sass.renderSync(scssStr), expectedRender));
it('should match compiled string with renderSync', function(done) {
done(assert.equal(sass.renderSync(sample.input), sample.expectedRender));
});
it("should throw an exception for bad input", function(done) {
it('should throw an exception for bad input', function(done) {
done(assert.throws(function() {
sass.renderSync(badInput);
sass.renderSync(sample.badInput);
}));

@@ -77,6 +47,6 @@ });

describe("compile scss", function() {
it("should compile with render", function(done) {
describe('compile scss', function() {
it('should compile with render', function(done) {
sass.render({
data: scssStr,
data: sample.input,
success: function(css) {

@@ -88,11 +58,11 @@ done(assert.ok(css));

it("should compile with renderSync", function(done) {
done(assert.ok(sass.renderSync({data: scssStr})));
it('should compile with renderSync', function(done) {
done(assert.ok(sass.renderSync({data: sample.input})));
});
it("should match compiled string with render", function(done) {
it('should match compiled string with render', function(done) {
sass.render({
data: scssStr,
data: sample.input,
success: function(css) {
done(assert.equal(css, expectedRender));
done(assert.equal(css, sample.expectedRender));
},

@@ -105,3 +75,3 @@ error: function(error) {

it("should have a error status of 1 for bad css", function(done) {
it('should have a error status of 1 for bad css', function(done) {
sass.render({

@@ -119,9 +89,9 @@ data: '{zzz}',

it("should match compiled string with renderSync", function(done) {
done(assert.equal(sass.renderSync({data: scssStr}), expectedRender));
it('should match compiled string with renderSync', function(done) {
done(assert.equal(sass.renderSync({data: sample.input}), sample.expectedRender));
});
it("should throw an exception for bad input", function(done) {
it('should throw an exception for bad input', function(done) {
done(assert.throws(function() {
sass.renderSync({data: badInput});
sass.renderSync({data: sample.badInput});
}));

@@ -131,9 +101,9 @@ });

describe("compile file with include paths", function(){
it("should compile with render", function(done) {
describe('compile file with include paths', function(){
it('should compile with render', function(done) {
sass.render({
file: path.resolve(__dirname, "include_path.scss"),
includePaths: [path.resolve(__dirname, "lib"), path.resolve(__dirname, "functions")],
file: path.resolve(__dirname, 'include_path.scss'),
includePaths: [path.resolve(__dirname, 'lib'), path.resolve(__dirname, 'functions')],
success: function (css) {
done(assert.equal(css, "body {\n background: red;\n color: #0000fe; }\n"));
done(assert.equal(css, 'body {\n background: red;\n color: #0000fe; }\n'));
},

@@ -147,9 +117,9 @@ error: function (error) {

describe("compile file with image path", function(){
it("should compile with render", function(done) {
describe('compile file with image path', function(){
it('should compile with render', function(done) {
sass.render({
file: path.resolve(__dirname, "image_path.scss"),
file: path.resolve(__dirname, 'image_path.scss'),
imagePath: '/path/to/images',
success: function (css) {
done(assert.equal(css, "body {\n background-image: url(\"/path/to/images/image.png\"); }\n"));
done(assert.equal(css, 'body {\n background-image: url("/path/to/images/image.png"); }\n'));
},

@@ -163,8 +133,8 @@ error: function (error) {

describe("compile file", function() {
it("should compile with render", function(done) {
describe('compile file', function() {
it('should compile with render', function(done) {
sass.render({
file: sampleFilename,
success: function (css) {
done(assert.equal(css, expectedRender));
done(assert.equal(css, sample.expectedRender));
},

@@ -177,11 +147,11 @@ error: function (error) {

it("should compile with renderSync", function(done) {
it('should compile with renderSync', function(done) {
done(assert.ok(sass.renderSync({file: sampleFilename})));
});
it("should match compiled string with render", function(done) {
it('should match compiled string with render', function(done) {
sass.render({
file: sampleFilename,
success: function(css) {
done(assert.equal(css, expectedRender));
done(assert.equal(css, sample.expectedRender));
},

@@ -194,7 +164,7 @@ error: function(error) {

it("should match compiled string with renderSync", function(done) {
done(assert.equal(sass.renderSync({file: sampleFilename}), expectedRender));
it('should match compiled string with renderSync', function(done) {
done(assert.equal(sass.renderSync({file: sampleFilename}), sample.expectedRender));
});
it("should throw an exception for bad input", function(done) {
it('should throw an exception for bad input', function(done) {
done(assert.throws(function() {

@@ -206,3 +176,3 @@ sass.renderSync({file: badSampleFilename});

describe("render to file", function() {
describe('render to file', function() {
var outFile = path.resolve(__dirname, 'out.css'),

@@ -221,3 +191,3 @@ filesWritten;

});
it("should compile with renderFile", function(done) {
it('should compile with renderFile', function(done) {
sass.renderFile({

@@ -228,3 +198,3 @@ file: sampleFilename,

var contents = filesWritten[outFile];
done(assert.equal(contents, expectedRender));
done(assert.equal(contents, sample.expectedRender));
},

@@ -237,3 +207,3 @@ error: function (error) {

it("should raise an error for bad input", function(done) {
it('should raise an error for bad input', function(done) {
sass.renderFile({

@@ -243,7 +213,7 @@ file: badSampleFilename,

success: function() {
assert(false, "success() should not be called");
assert(false, 'success() should not be called');
done();
},
error: function() {
assert(true, "error() called");
assert(true, 'error() called');
done();

@@ -254,3 +224,3 @@ }

it("should save the sourceMap to the default file name", function(done) {
it('should save the sourceMap to the default file name', function(done) {
sass.renderFile({

@@ -275,3 +245,3 @@ file: sampleFilename,

it("should save the sourceMap to a specified file name", function(done) {
it('should save the sourceMap to a specified file name', function(done) {
var mapFileName = 'foo.css.map';

@@ -296,2 +266,2 @@ sass.renderFile({

});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc