Skip to content

Instantly share code, notes, and snippets.

@josephj
Created July 2, 2014 23:46
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 josephj/140ebc84e249e7b6054b to your computer and use it in GitHub Desktop.
Save josephj/140ebc84e249e7b6054b to your computer and use it in GitHub Desktop.
{
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"jslint_happy": true,
"preserve_newlines": true,
"space_in_paren": false,
"keep_function_indentation": true
}
glob = require 'glob'
path = require 'path'
exec = require('child_process').exec
js_beautify = require('js-beautify').js_beautify
log = (msg) ->
console.log(msg)
# Format JavaScript
glob 'app/media/js/**/*.js', null, (err, files) ->
cmd = []
total = 0
for file in files
if file.indexOf('app/media/js/admin/ace') is -1 and
file.indexOf('.min.js') is -1 and
file.indexOf('.min.gz.js') is -1
log file
cmd.push "js-beautify -r --config=~/stackla-web/config.json #{file}"
total += 1
log "==============================================="
log " Processing #{total} JavaScript files..."
log "==============================================="
exec cmd.join(';'), (error, stdout, stderr) ->
console.log "exec error: #{error}" if (error)
# Format CSS
glob 'app/media/css/**/*.css', null, (err, files) ->
cmd = []
total = 0
for file in files
if file.indexOf('.min.css') is -1 and
file.indexOf('.min.gz.css') is -1
log file
filename = path.basename(file)
cmd.push "expand -t 4 '#{file}' > /tmp/#{filename} && mv /tmp/#{filename} '#{file}'"
total += 1
log "==============================================="
log " Processing #{total} CSS files..."
log "==============================================="
exec cmd.join(';'), (error, stdout, stderr) ->
console.log "exec error: #{error}" if (error)
# Format SCSS
glob 'app/media/css/**/*.scss', null, (err, files) ->
cmd = []
total = 0
for file in files
log file
filename = path.basename(file)
cmd.push "expand -t 4 '#{file}' > /tmp/#{filename} && mv /tmp/#{filename} '#{file}'"
total += 1
log "==============================================="
log " Processing #{total} SCSS files..."
log "==============================================="
exec cmd.join(';'), (error, stdout, stderr) ->
console.log "exec error: #{error}" if (error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment