Permalink
Browse files

add verbose option to some processors

  • Loading branch information...
1 parent 2629dcb commit e4dfb842fe9c6d8e2959f99005fc00ed90e337e0 @kof committed Feb 15, 2012
@@ -14,7 +14,8 @@ var utils = require('../utils'),
* @export
*/
exports.options = {
- pattern: /\.css$/
+ pattern: /\.css$/,
+ verbose: false
};
// @import "../style.css" all print;
@@ -54,7 +55,9 @@ exports.run = function(path, data, o) {
try {
pathname = utils.resolvePath(url, path, self.root, paths);
} catch(err) {
- console.error(err.message);
+ if (o.verbose) {
+ console.log(err.message);
+ }
return url;
}
@@ -57,7 +57,7 @@ exports.run = function run(path, data, o) {
return search;
}
-
+
fakeBuild = cloneObject(self);
fakeBuild.data = {};
fakeBuild.data[importPath] = n.fs.readFileSync(importPath);
@@ -21,7 +21,8 @@ exports.options = {
maxSize: 32768,
html: true,
- css: true
+ css: true,
+ verbose: false
};
@@ -94,7 +95,9 @@ exports.run = function(path, data, o) {
try {
resolvedPath = utils.resolvePath(url, path, self.root, paths);
} catch(err) {
- console.error(err.message);
+ if (o.verbose) {
+ console.log(err.message);
+ }
}
}
@@ -13,7 +13,8 @@ var utils = require('../utils'),
* @export
*/
exports.options = {
- pattern: /\.html$/
+ pattern: /\.html$/,
+ verbose: false
};
// <link href="css/index.css" rel="stylesheet" type="text/css" />
@@ -54,7 +55,9 @@ exports.run = function(path, data, o) {
try {
pathname = utils.resolvePath(url, path, self.root, paths);
} catch(err) {
- console.error(err.message);
+ if (o.verbose) {
+ console.log(err.message);
+ }
return url;
}
@@ -46,12 +46,12 @@ function tmpl(id, deps, body) {
exports.run = function(path, data, o) {
var deps = parse(data),
self = this;
-
+
// check if paths exist
deps.forEach(function(dep) {
- resolvePath(dep, path, self.root, self.paths);
+ resolvePath(dep, path, self.root, self.paths);
});
-
+
// convert abs path to relative one
if (path.substr(0, 1) === '/') {
this.paths.forEach(function(lookupPath) {
@@ -66,9 +66,9 @@ exports.run = function(path, data, o) {
// remove ext from the name
path = path.substr(0, path.length - extname(path).length);
-
+
deps.unshift('require', 'exports', 'module');
- return tmpl(path, deps, data);
+ return tmpl(path, deps, data);
};
@@ -13,7 +13,8 @@ var min = require('uglify-js');
* @export
*/
exports.options = {
- pattern: /\.js$/
+ pattern: /\.js$/,
+ verbose: false
};
/**
@@ -27,6 +28,11 @@ exports.options = {
*/
exports.run = function(path, data, o) {
var ast = min.parser.parse(data);
+
+ if (o.verbose) {
+ min.uglify.set_logger(console.log);
+ }
+
ast = min.uglify.ast_mangle(ast);
ast = min.uglify.ast_squeeze(ast);
return min.uglify.gen_code(ast);
View
@@ -1,7 +1,7 @@
{
"name": "ams",
"description": "ams - asset management system - plugin enabled build tool with jquery like API",
- "version": "0.0.18",
+ "version": "0.0.19",
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
"repository": "git://github.com/kof/node-ams.git",
"keywords": [
View
@@ -98,7 +98,8 @@ Example:
build.process({
uglifyjs: false,
cssabspath: {
- host: 'http://localhost:8888'
+ host: 'http://localhost:8888',
+ verbose: true
}
})
@@ -155,12 +156,17 @@ Write a success message to stdout, pass a message string optionally. Returns bui
// change processors options
.process({
cssabspath: {
- host: host
+ host: host,
+ verbose: true
},
htmlabspath: {
- host: host
+ host: host,
+ verbose: true
},
- texttransport: false
+ texttransport: false,
+ uglifyjs: {
+ verbose: true
+ }
})
// combine all js files
.combine({
View
@@ -2,8 +2,8 @@ QUnit.module('uglifyjs');
test('minify js code', 1, function() {
equal(
- run('test/test.js', 'exports.test = 123;\n var test = "test";\n'),
+ run('test/test.js', 'exports.test = 123;\n var test = "test";\n', {}),
'exports.test=123;var test="test"',
- 'minifier works'
+ 'minifier works'
);
});

0 comments on commit e4dfb84

Please sign in to comment.