Socket
Socket
Sign inDemoInstall

rework

Package Overview
Dependencies
5
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.3.0

bin/rework

10

History.md
0.3.0 / 2012-09-06
==================
* add `rework(1)`. Closes #4
0.2.0 / 2012-09-04
==================
* add vendor support to at2x [Simen Brekken]
0.1.2 / 2012-09-01

@@ -3,0 +13,0 @@ ==================

69

lib/plugins/at2x.js

@@ -12,34 +12,36 @@

* Translate
*
*
* .logo {
* background-image: url('/public/images/logo.png')
* }
*
* background-image: url('/public/images/logo.png')
* }
*
* yields:
*
*
* .logo {
* background-image: url('/public/images/logo.png')
* }
*
* @media all and (-webkit-min-device-pixel-ratio : 1.5) {
* .logo {
* background-image: url("/public/images/logo@2x.png")
* }
* }
*
* background-image: url('/public/images/logo.png')
* }
*
* @media all and (-webkit-min-device-pixel-ratio : 1.5) {
* .logo {
* background-image: url("/public/images/logo@2x.png")
* }
* }
*
*/
module.exports = function(vendors) {
return function(style, rework){
vendors = vendors || rework.prefixes;
function prefix(value) {
return '(' + vendors.map(function(vendor) {
return vendor + value;
}).join(' or ') + ')';
}
style.rules.forEach(function(rule){
function visit(rules, style, media) {
rules.forEach(function(rule){
if (rule.media) return visit(rule.rules, style, rule.media);
if (!rule.declarations) return;
rule.declarations.forEach(function(decl){
var i = decl.value.indexOf('url(');
// no url()
if (-1 == i) return;
rule.declarations.filter(backgroundWithURL).forEach(function(decl){
// parse url
var i = decl.value.indexOf('url(');
var url = stripQuotes(decl.value.slice(i + 4, decl.value.indexOf(')', i)));

@@ -53,3 +55,3 @@ var ext = path.extname(url);

style.rules.push({
media: 'all and (-webkit-min-device-pixel-ratio: 1.5)',
media: [media || 'all', prefix('min-device-pixel-ratio: 1.5')].join(' and '),
rules: [

@@ -60,3 +62,3 @@ {

{
property: decl.property,
property: 'background-image',
value: 'url("' + url + '")'

@@ -70,3 +72,18 @@ }

});
}
};
};
return function(style, rework) {
vendors = vendors || rework.prefixes;
visit(style.rules, style);
};
};
/**
* Filter background[-image] with url().
*/
function backgroundWithURL(decl) {
return ('background' == decl.property
|| 'background-image' == decl.property)
&& ~decl.value.indexOf('url(');
}
{
"name": "rework",
"version": "0.1.2",
"version": "0.3.0",
"description": "CSS manipulations built on CSSOM",
"keywords": ["css", "manipulation", "preprocess", "transform"],
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"bin": {
"rework": "./bin/rework"
},
"dependencies": {
"css": "1.0.3"
"css": "1.0.3",
"commander": "1.0.4"
},

@@ -10,0 +14,0 @@ "devDependencies": {

@@ -1,5 +0,4 @@

# rework
CSS manipulations built on [node-css](github.com/visionmedia/node-css),
CSS manipulations built on [node-css](//github.com/visionmedia/node-css),
allowing you to automate vendor prefixing, create your own properties,

@@ -18,2 +17,23 @@ inline images, anything you can imagine!

## rework(1)
```js
Usage: rework [options]
Options:
-h, --help output usage information
-V, --version output the version number
-v, --vendors <list> specify list of vendors
```
for example:
```
$ rework -v webkit,moz < my.css > my.reworked.css
```
## API

@@ -20,0 +40,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc