### How to use clean-css programatically ###
- var CleanCSS = require('clean-css').CleanCSS;
+ var cleanCSS = require('clean-css');
- var source = "a{font-weight:bold}";
- var minimized = CleanCSS.process(source);
+ var source = "a{font-weight:bold;}";
+ var minimized = cleanCSS.process(source);
### How to run clean-css tests? ###
#!/usr/bin/env node
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
-var CleanCSS = require('clean-css').CleanCSS,
+var argv = require('optimist').argv,
+ cleanCss = require('clean-css'),
fs = require('fs');
var options = {
target: null
};
-var args = process.argv.slice(2);
-out: while (args.length > 0) {
- var p = args.shift();
- switch(p) {
- case '-o':
- options.target = args.shift();
- break;
- default:
- options.source = args.shift();
- }
+if (argv.o) options.target = argv.o;
+if (argv._) options.source = argv._[0];
+
+if (argv.h || argv.help) {
+ global.sys.print('Usage: cleancss -o <output-file> <input-file>\n');
+ process.exit(0);
}
if (options.source) {
fs.readFile(options.source, 'utf8', function(error, text) {
if (error) throw error;
- output(CleanCSS.process(text));
+ output(cleanCss.process(text));
});
} else {
var stdin = process.openStdin();
stdin.setEncoding('utf-8');
var text = '';
stdin.on('data', function(chunk) { text += chunk; });
- stdin.on('end', function() { output(CleanCSS.process(text)); });
+ stdin.on('end', function() { output(cleanCss.process(text)); });
}
function output(cleaned) {
-exports.CleanCSS = require("./lib/clean");
\ No newline at end of file
+module.exports = require("./lib/clean");
\ No newline at end of file
}
};
-exports.CleanCSS = CleanCSS;
\ No newline at end of file
+module.exports = CleanCSS;
\ No newline at end of file
"type" : "git",
"url" : "http://github.com/jakubpawlowicz/clean-css.git"
},
- "version": "0.1.0",
+ "version": "0.2.0",
"main": "index.js",
"bin": {
"cleancss": "./bin/cleancss"
+ },
+ "dependencies": {
+ "optimist": "0.1.x"
}
}
\ No newline at end of file
var vows = require('vows'),
fs = require('fs'),
- assert = require('assert');
-
-var CleanCSS = require('../lib/clean').CleanCSS;
+ assert = require('assert'),
+ cleanCSS = require('../index');
var batchContexts = function() {
var context = {};
}
}
context[testName]['minimizing ' + testName + '.css'] = function(data) {
- assert.equal(CleanCSS.process(data.plain), data.minimized)
+ assert.equal(cleanCSS.process(data.plain), data.minimized)
};
});
var vows = require('vows'),
- assert = require('assert');
-
-var CleanCSS = require('../lib/clean').CleanCSS;
+ assert = require('assert'),
+ cleanCSS = require('../index');
var cssContext = function(groups) {
var context = {};
- var clean = function(cleanCss) {
+ var clean = function(cleanedCSS) {
return function(css) {
- assert.equal(CleanCSS.process(css), cleanCss);
+ assert.equal(cleanCSS.process(css), cleanedCSS);
}
};