Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Last active August 29, 2015 14:05
Show Gist options
  • Save fivetanley/10d24e2f6f13a299df5b to your computer and use it in GitHub Desktop.
Save fivetanley/10d24e2f6f13a299df5b to your computer and use it in GitHub Desktop.
Move files over for Ember CLI with this one weird trick.
# Script to rename underscored files to dasherized
# Example: changes app/models/foo_thing.js to app/models/foo-thing.js
# Ember CLI decided dashes for consistency, so let's change it over
# to that!
# First, install active support with gem install activesupport
# Run with "ruby convert_for_ember_cli.rb"
require 'fileutils'
require 'active_support/core_ext/string'
# Replace app,test with your filenames.
Dir['{app,test,spec}/**/*.{coffee,js,hbs}'].uniq.each do |file|
new_filename = file.underscore.dasherize.gsub('-spec', '-test')
puts "moving #{file} to #{new_filename}"
FileUtils.mkdir_p File.dirname new_filename
FileUtils.mv file, new_filename, :force => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment