js-adler32/bin/adler32.njs
SheetJS b692b3f7df version bump 0.4.0
- simplified utf8 code
- added browser demo
- added command line tool adler32
- fixed unicode baseline script (node 6 changed default array printing)
- fixed performance tests (benchmark module changed behavior)
- updated travis versions for test
- miscellaneous adjustments to tooling
2016-06-16 12:56:55 -04:00

38 lines
945 B
JavaScript
Executable File

#!/usr/bin/env node
/* adler32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2 ft=javascript: */
var X;
try { X = require('../'); } catch(e) { X = require('adler-32'); }
var fs = require('fs');
require('exit-on-epipe');
var args = process.argv.slice(2);
var filename;
if(args[0]) filename = args[0];
if(!process.stdin.isTTY) filename = filename || "-";
if(!filename) {
console.error("adler32: must specify a filename ('-' for stdin)");
process.exit(1);
}
if(filename === "-h" || filename === "--help") {
console.log("usage: " + process.argv[0] + " [filename]");
process.exit(0);
}
if(filename !== "-" && !fs.existsSync(filename)) {
console.error("adler32: " + filename + ": No such file or directory");
process.exit(2);
}
if(filename === "-") process.stdin.pipe(require('concat-stream')(process_data));
else process_data(fs.readFileSync(filename));
function process_data(data) {
console.log(X.buf(data));
}