Skip to content

Instantly share code, notes, and snippets.

@japboy
Created October 13, 2016 15:42
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 japboy/4ec74686d46d2a99132ae38ecedf4bc3 to your computer and use it in GitHub Desktop.
Save japboy/4ec74686d46d2a99132ae38ecedf4bc3 to your computer and use it in GitHub Desktop.
/**
* UTF-8 から SJIS に一括変換するスクリプト
*/
const fs = require('fs');
const glob = require('glob');
const iconv = require('iconv');
const pattern = './assets/**/*';
const files = glob.sync(pattern).filter((file) => fs.statSync(file).isFile());
files.forEach((file) => {
const conv = new iconv.Iconv('UTF-8', 'SHIFT_JIS');
const filein = fs.createReadStream(file);
const fileout = fs.createWriteStream(file);
filein
.pipe(conv)
.pipe(fileout);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment