remove options that no longer work, fix #55
This commit is contained in:
parent
f4f960770c
commit
19482586f9
96
bin/messc
96
bin/messc
@ -4,13 +4,11 @@ var path = require('path'),
|
||||
fs = require('fs'),
|
||||
sys = require('sys');
|
||||
|
||||
require.paths.unshift(path.join(__dirname, '..', 'lib'));
|
||||
require.paths.unshift(path.join(__dirname, '../lib'), path.join(__dirname, '../lib/node'));
|
||||
|
||||
var mess = require('mess');
|
||||
var args = process.argv.slice(1);
|
||||
var options = {
|
||||
compress: false,
|
||||
optimization: 1,
|
||||
silent: false,
|
||||
json: false
|
||||
};
|
||||
@ -29,8 +27,6 @@ args = args.filter(function (arg) {
|
||||
case 'verbose':
|
||||
options.verbose = true;
|
||||
break;
|
||||
case 'j':
|
||||
options.json = true;
|
||||
case 'd':
|
||||
options.debug = true;
|
||||
case 's':
|
||||
@ -43,17 +39,6 @@ args = args.filter(function (arg) {
|
||||
sys.puts("Options:");
|
||||
sys.puts(" -j\tParse JSON map manifest");
|
||||
process.exit(0);
|
||||
case 'l':
|
||||
case 'layers':
|
||||
options.layers = true;
|
||||
break;
|
||||
case 'x':
|
||||
case 'compress':
|
||||
options.compress = true;
|
||||
break;
|
||||
case 'O0': options.optimization = 0; break;
|
||||
case 'O1': options.optimization = 1; break;
|
||||
case 'O2': options.optimization = 2; break;
|
||||
}
|
||||
});
|
||||
|
||||
@ -66,7 +51,7 @@ if (output && output[0] != '/') {
|
||||
output = path.join(process.cwd(), output);
|
||||
}
|
||||
|
||||
if (! input) {
|
||||
if (!input) {
|
||||
sys.puts("messc: no input files");
|
||||
process.exit(1);
|
||||
}
|
||||
@ -77,70 +62,15 @@ fs.readFile(input, 'utf-8', function (e, data) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (options.layers) {
|
||||
// Loads layer definitions from a .layers file in the same directory
|
||||
// as the .mss file with the same basename.
|
||||
var layerFile = input.replace(/\.\w+$/, '.layers');
|
||||
|
||||
fs.readFile(layerFile, 'utf-8', function(err, layers) {
|
||||
if (err) {
|
||||
sys.puts("messc: " + err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var m = '{ "Stylesheet": [{ "id": "' + input +'", "data": "' + data.replace(/\n/g, '\\n') + '" }], "Layer": ' + layers + ' }';
|
||||
new mess.Renderer({
|
||||
paths: [path.dirname(input)],
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).render(m, function(err, output) {
|
||||
if (err) {
|
||||
mess.writeError(err, options);
|
||||
process.exit(1);
|
||||
} else {
|
||||
sys.puts(output);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (options.json) {
|
||||
new mess.Renderer({
|
||||
paths: [path.dirname(input)],
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).render(data, function (err, output) {
|
||||
if (err) {
|
||||
mess.writeError(err, options);
|
||||
process.exit(1);
|
||||
} else {
|
||||
sys.puts(output);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
new mess.Parser({
|
||||
paths: [path.dirname(input)],
|
||||
optimization: options.optimization,
|
||||
filename: input
|
||||
}).parse(data, function (err, tree) {
|
||||
if (err) {
|
||||
mess.writeError(err, options);
|
||||
// process.exit(1);
|
||||
} else {
|
||||
try {
|
||||
// if (options.debug) {
|
||||
// try {
|
||||
// require('eyes').inspect(tree.toAST());
|
||||
// } catch (e) {
|
||||
// console.log(e);
|
||||
// console.log(tree.toAST());
|
||||
// }
|
||||
// }
|
||||
var mss = tree.toMSS({ compress: options.compress });
|
||||
sys.print(mss);
|
||||
} catch (e) {
|
||||
mess.writeError(e, options);
|
||||
// process.exit(2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
new mess.Renderer({
|
||||
filename: input,
|
||||
local_data_dir: path.dirname(input),
|
||||
}).render(data, function(err, output) {
|
||||
if (err) {
|
||||
mess.writeError(err, options);
|
||||
process.exit(1);
|
||||
} else {
|
||||
sys.puts(output);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -46,8 +46,6 @@ External.prototype.downloadFile = function() {
|
||||
this.env.data_dir,
|
||||
crypto.createHash('md5').update(this.uri).digest('hex') + path.extname(this.uri));
|
||||
|
||||
console.log('downloading to: ' + this.tempPath);
|
||||
|
||||
fs.stat(this.path(), function(err, stats) {
|
||||
if (err) {
|
||||
// This file does not yet exist. Download it!
|
||||
|
@ -185,15 +185,7 @@ mess.Parser = function Parser(env) {
|
||||
}
|
||||
|
||||
this.env = env = env || {};
|
||||
|
||||
// The optimization level dictates the thoroughness of the parser,
|
||||
// the lower the number, the mess nodes it will create in the tree.
|
||||
// This could matter for debugging, or if you want to access
|
||||
// the individual nodes in the tree.
|
||||
this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
|
||||
|
||||
this.env.filename = this.env.filename || null;
|
||||
|
||||
this.env.error = function(e) {
|
||||
if (!env.errors) env.errors = [];
|
||||
env.errors.push(e);
|
||||
|
@ -15,21 +15,6 @@ require.paths.unshift(path.join(__dirname, '..', 'lib'));
|
||||
* This is node-only for the time being.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert a two-element-per-item Array
|
||||
* into an object, for the purpose of checking membership
|
||||
* and replacing stuff.
|
||||
* @param {Array} list a list.
|
||||
*/
|
||||
var to = function(list) {
|
||||
return list && list[0] && _.reduce(list, function(m, r) {
|
||||
if (r && r.length > 1) {
|
||||
m[r[0]] = r[1];
|
||||
}
|
||||
return m;
|
||||
}, {});
|
||||
};
|
||||
|
||||
mess.Renderer = function Renderer(env) {
|
||||
env = _.extend(env, {});
|
||||
if (!env.data_dir) env.data_dir = '/tmp/';
|
||||
|
Loading…
Reference in New Issue
Block a user