Socket
Socket
Sign inDemoInstall

analyze-css

Package Overview
Dependencies
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analyze-css - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

examples/sass.sass

37

lib/preprocessors/sass.js

@@ -14,7 +14,8 @@ /**

matchesFileName: function(fileName) {
return /\.scss$/.test(fileName);
return /\.(scss|sass)$/.test(fileName);
},
process: function(css, options) {
var path = require('path'),
sass = require('node-sass');
sass = require('node-sass'),
out;

@@ -24,9 +25,29 @@ var includeDir = path.dirname(options.file);

return sass.renderSync({
data: css,
includePaths: [
includeDir
]
});
try {
// 1: try to parse using SCSS syntax (i.e. with brackets)
debug('Parsing using SCSS syntax');
out = sass.renderSync({
data: css,
indentedSyntax: false,
includePaths: [
includeDir
]
});
} catch (e) {
// 2: try to parse using SASS syntax (i.e. with indends) - issue #79
debug('Exception: %s', e.toString().trim());
debug('Parsing using SASS syntax as a fallback');
out = sass.renderSync({
data: css,
indentedSyntax: true,
includePaths: [
includeDir
]
});
}
return out;
}
};
{
"name": "analyze-css",
"version": "0.9.0",
"version": "0.9.1",
"author": "Maciej Brencz <maciej.brencz@gmail.com> (https://github.com/macbre)",

@@ -28,3 +28,3 @@ "description": "CSS selectors complexity and performance analyzer",

"glob": "~4.0.5",
"node-sass": "~1.0.3",
"node-sass": "1.1.2",
"onecolor": "2.4.x",

@@ -31,0 +31,0 @@ "optimist": "0.6.x",

@@ -6,3 +6,4 @@ /*global describe, it */

assert = require('assert'),
css = 'nav {\nul{ color: white }\n}';
scss = 'nav {\nul{ color: white }\n}',
sass = 'nav\n\tul\n\t\tcolor: white\n';

@@ -14,3 +15,3 @@ describe('SASS preprocessor', function() {

assert.equal(preprocessors.findMatchingByFileName('test/foo.scss'), 'sass');
assert.equal(preprocessors.findMatchingByFileName('test/foo.sass'), false);
assert.equal(preprocessors.findMatchingByFileName('test/foo.sass'), 'sass');
assert.equal(preprocessors.findMatchingByFileName('test/foo.css'), false);

@@ -20,3 +21,3 @@ });

it('should raise an error (if not selected)', function(done) {
new analyzer(css, function(err, res) {
new analyzer(scss, function(err, res) {
assert.equal(err && /CSS parsing failed/.test(err), true);

@@ -27,4 +28,4 @@ done();

it('should generate CSS correctly', function(done) {
new analyzer(css, {
it('should generate CSS from SCSS correctly', function(done) {
new analyzer(scss, {
preprocessor: 'sass'

@@ -37,2 +38,12 @@ }, function(err, res) {

});
it('should generate CSS from SASS correctly', function(done) {
new analyzer(sass, {
preprocessor: 'sass'
}, function(err, res) {
assert.strictEqual(err, null);
assert.equal(res.metrics.selectors, 1);
done();
});
});
});
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