Created
May 1, 2014 11:32
-
-
Save tancredi/232e00f68842a0b88bdc to your computer and use it in GitHub Desktop.
Quick script to flip text horizontally (Needed to fix some ASCII art)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var src = process.argv[2], | |
out = '', | |
text; | |
if (!src) { | |
console.error('Arguments: source_file'); | |
process.exit(1); | |
} | |
if (!fs.existsSync(src)) { | |
console.error('Source file not fond'); | |
process.exit(1); | |
} | |
text = fs.readFileSync(src, 'utf8'); | |
text.split('\n').forEach(function (line) { | |
for (var i = line.length - 1; i >= 0; i -= 1) { | |
out += line[i]; | |
} | |
out += '\n'; | |
}); | |
console.log(out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment