Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add dashes to CoffeeScript source. toString ⇒ to-string. Issue #2370
fs = require 'fs'
# Usage: coffee src/**/*
replaceFile = (path) ->
fs.readFile path, (error, data) ->
return console.log error if error?
result = data
.replace /([a-z])([A-Z])([a-z])/g, ($0, $1, $2, $3) ->
$1 + '-' + $2.toLowerCase() + $3
console.log 'Replacing', path
fs.writeFile path, result
replaceFiles = (paths) ->
paths.forEach replaceFile
replaceFiles process.argv[2..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.