Skip to content

Instantly share code, notes, and snippets.

@meritt
Created November 23, 2012 07:57
Show Gist options
  • Save meritt/4134442 to your computer and use it in GitHub Desktop.
Save meritt/4134442 to your computer and use it in GitHub Desktop.
Обновление версии для статики в шаблонах сайта
(root, fn) ->
glob 'views/**/*.hbs', {}, (error, files) ->
for file in files
source = fs.readFileSync "#{root}/#{file}", 'utf8'
update = false
for filename, version of options.version
if source.indexOf(filename) > -1
update = true
[name, extension] = filename.split '.'
source = source.replace filename, "#{name}.v#{version}.#{extension}"
if update is true
fs.writeFileSync "#{root}/#{file}", source
console.log "Update version for #{file}"
fn root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment