Skip to content

Instantly share code, notes, and snippets.

@vsemozhetbyt
Created January 17, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsemozhetbyt/4ea159ea259008a86a4b to your computer and use it in GitHub Desktop.
Save vsemozhetbyt/4ea159ea259008a86a4b to your computer and use it in GitHub Desktop.
'use strict';
/******************************************************************************/
const path = process.argv[2];
if (!path) {
console.log('Add the file path, please.');
process.exit();
}
/******************************************************************************/
const fs = require('fs');
const rl = require('readline').createInterface({
input: fs.createReadStream(path, 'utf8'), //ascii utf8 utf16le
terminal: false,
historySize: 0
});
const outfile = fs.openSync(path.replace(/(\.[^.]+)?$/, '.new$1'), 'w');
/******************************************************************************/
rl.on('line', function(line) {
fs.writeSync(outfile, `${
line
.replace(/\[m2\]\[i\]/, '[m2][*][i]')
.replace(/\[\/i\]\[\/m\]/, '[/i][/*][/m]')
}\n`, null, 'utf8');
});
/******************************************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment