Created
July 30, 2016 07:08
-
-
Save duaraghav8/966d53a11c6a063483b8bbd350fb5dc8 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
'use strict'; | |
/* | |
tabber.js: Add N extra tabs at the beginning of each line of code | |
usage: | |
./tabber.js <filename> <no_of_tabs> > <output_filename> | |
*/ | |
let fRead = require ('fs').readFileSync, | |
args = process.argv; | |
let code = fRead (args [2], 'utf8').split (''), | |
extension = Array (Number (args [3]) + 1).join ('\t'); | |
code [0] = extension + code [0]; | |
for (let i = 0; i < code.length; i++) { | |
if (code [i] === '\n') { | |
code [i] = '\n' + extension; | |
} | |
} | |
console.log (code.join ('')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment