Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Forked from domenic/remove-bom.js
Created June 19, 2012 15:54
Show Gist options
  • Save vendethiel/2954951 to your computer and use it in GitHub Desktop.
Save vendethiel/2954951 to your computer and use it in GitHub Desktop.
Removing BOM
global[r] = require r for r of <[js path wrench]>
BOM = String.fromCharCode BOM_CHAR_CODE = 65279
wrench.readdirSyncRecursive process.cwd! .forEach (filename) ->
return unless \js is path.extname filename
error, content <-! fs.readFile fileName, \utf8
throw that if error
unless content.charCodeAt 0 is BOM_CHAR_CODE
fs.writeFile content, BOM + @@1, \utf8 -> throw it if it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment