Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uncss

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uncss - npm Package Compare versions

Comparing version 0.7.7 to 0.7.8

41

lib/lib.js

@@ -23,24 +23,29 @@ 'use strict';

timeout
];
],
buffer = '',
error = '';
require('child_process').execFile(phantom.path, childArgs, function (err, stdout, stderr) {
/* Filter OSX-specific error */
var isNot192OSXError = (err || stderr || '').indexOf('WARNING: Method userSpaceScaleFactor') === -1,
isNotPerformanceNote = (err || stderr || '').indexOf('CoreText performance note:') === -1;
var instance = require('child_process').spawn(phantom.path, childArgs);
instance.stdout.setEncoding('utf8');
instance.stderr.setEncoding('utf8');
/* istanbul ignore if: not testable */
if (err) {
if (isNot192OSXError && isNotPerformanceNote) {
return callback(err);
}
instance.stdout.on('data', function (data) {
buffer += data;
});
instance.stderr.on('data', function (error) {
/* Ignore PhantomJS 1.9.2 OSX errors */
var bufferStr = error + '',
isNot192OSXError = bufferStr.indexOf('WARNING: Method userSpaceScaleFactor') === -1,
isNotPerformanceNote = bufferStr.indexOf('CoreText performance note:') === -1;
if (isNot192OSXError && isNotPerformanceNote) {
error += bufferStr;
}
/* istanbul ignore if: not testable */
if (stderr) {
/* Our error */
if (isNot192OSXError && isNotPerformanceNote) {
return callback(stderr);
}
});
instance.on('close', function (code) {
if (code === 0 && error === '') {
callback(null, buffer);
} else {
callback(error);
}
/* Success */
return callback(null, stdout);
});

@@ -47,0 +52,0 @@ }

@@ -34,6 +34,6 @@ 'use strict';

/* Ignore specified stylesheets */
if (options.ignore_sheets.length > 0) {
if (options.ignoreSheets.length > 0) {
stylesheets = stylesheets.map(function (arr) {
return arr.filter(function (sheet) {
return _.every(options.ignore_sheets, function (ignore) {
return _.every(options.ignoreSheets, function (ignore) {
if (_.isRegExp(ignore)) {

@@ -105,3 +105,12 @@ return !ignore.test(sheet);

} catch (err) {
err.message = 'node_modules/css: ' + err.message;
/* Try to construct an helpful error message */
if (err.line) {
var line = css_str.split('\n')[err.line - 1];
/* It could be minified CSS */
if (line.length > 20 && err.column) {
line = line.substr(err.column - 10, err.column + 10);
}
err.message += '\n -> ' + line;
}
err.message = 'uncss/node_modules/css: ' + err.message;
return callback(err);

@@ -155,3 +164,3 @@ }

options.report = options.report || false;
options.ignore_sheets = options.ignore_sheets || [];
options.ignoreSheets = options.ignoreSheets || [];

@@ -158,0 +167,0 @@ /* If 'files' is a string, it should represent an HTML page. */

{
"name": "uncss",
"version": "0.7.7",
"version": "0.7.8",
"author": "Giakki",

@@ -44,3 +44,3 @@ "description": "Remove unused CSS styles",

"css": "~1.6.0",
"phantomjs": "~1.9.2-6",
"phantomjs": "~1.9.7-1",
"request": "~2.33.0",

@@ -50,5 +50,4 @@ "underscore": "~1.5.2"

"devDependencies": {
"chai": "~1.8.1",
"chai-resemble": "~0.0.3",
"gm": "~1.14.2",
"chai": "~1.9.0",
"chai-resemble": "~0.2.0",
"grunt": "~0.4.2",

@@ -55,0 +54,0 @@ "grunt-contrib-jshint": "~0.8.0",

@@ -26,12 +26,12 @@ # UnCSS

options = {
ignore: ['#added_at_runtime', /test\-[0-9]+/],
media: ['(min-width: 700px) handheld and (orientation: landscape)'],
csspath: '../public/css/',
raw: 'h1 { color: green }',
stylesheets: ['lib/bootstrap/dist/css/bootstrap.css', 'src/public/css/main.css'],
ignore_sheets: [/fonts.googleapis/],
urls: ['http://localhost:3000/mypage', '...'] //array of urls
timeout: 1000,
report: true,
htmlroot: 'public'
ignore : ['#added_at_runtime', /test\-[0-9]+/],
media : ['(min-width: 700px) handheld and (orientation: landscape)'],
csspath : '../public/css/',
raw : 'h1 { color: green }',
stylesheets : ['lib/bootstrap/dist/css/bootstrap.css', 'src/public/css/main.css'],
ignoreSheets : [/fonts.googleapis/],
urls : ['http://localhost:3000/mypage', '...'] // Deprecated
timeout : 1000,
report : true,
htmlroot : 'public'
};

@@ -56,3 +56,3 @@

/* Specifying raw HTML
* NOTE: raw HTML is not parsed by phantom
* NOTE: raw HTML is not parsed by PhantomJS
*/

@@ -90,3 +90,3 @@ var raw_html = '...'

-s, --stylesheets <file, ...> Specify additional stylesheets to process
-S, --ignore_sheets <selector, ...> Do not include specified stylesheets
-S, --ignoreSheets <selector, ...> Do not include specified stylesheets
-r, --raw <string> Pass in a raw string of CSS

@@ -105,3 +105,3 @@ -t, --timeout <milliseconds> Wait for JS evaluation

- __ignore_sheets__ (Array): do not process these stylesheets, e.g. Google fonts. Accepts strings or regex patterns
- __ignoreSheets__ (Array): do not process these stylesheets, e.g. Google fonts. Accepts strings or regex patterns

@@ -111,2 +111,3 @@ - __raw__ (String): give the task a raw string of CSS in addition to the existing stylesheet options; useful in scripting when your CSS hasn't yet been written to disk.

- __urls__ (Array): array of URLs to load with Phantom (on top of the files already passed if any).
NOTE: this feature is deprecated, you can pass URLs directly as arguments.

@@ -117,6 +118,3 @@ - __timeout__ (Number): specify how long to wait for the JS to be loaded.

## Testing
The UnCSS test suite requires you to have imagemagick and graphicsmagick installed (Required by [gm](https://github.com/aheckmann/gm/)).
## License
Copyright (c) 2013 Giacomo Martino. See the [LICENSE](/LICENSE.md) file for license rights and limitations (MIT).

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