Skip to content

Instantly share code, notes, and snippets.

@aseemk
Created May 10, 2012 22:34
Show Gist options
  • Save aseemk/2656319 to your computer and use it in GitHub Desktop.
Save aseemk/2656319 to your computer and use it in GitHub Desktop.
Helper script to migrate Streamline files to the new ._js/._coffee extensions.
#!/usr/bin/env _coffee
#
# Migrates our Streamline v0.1 files to the new Streamline v0.3 extensions,
# i.e. git-moves all foo_.coffee files to foo._coffee.
{exec} = require 'child_process'
Path = require 'path'
# regex to recognize old-style streamline files:
STREAMLINE_REGEX = /_\.(js|coffee)$/
# step 1: get all checked-in files
files = exec 'git ls-files', _
files = files.trim().split '\n'
# step 2: iterate over all of them...
for file in files
# ignore the ones that aren't streamlined:
match = file.match STREAMLINE_REGEX
continue if not match
# for the ones that are, git mv them to the new extension:
# ( https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter )
before = file
after = file.replace STREAMLINE_REGEX, (str, type) -> "._#{type}"
exec "git mv '#{before}' '#{after}'", _
@gasi
Copy link

gasi commented May 11, 2012

Sweet. How come I can’t see any public gists for you? Is that on purpose?

@aseemk
Copy link
Author

aseemk commented May 11, 2012

Weird, I have no idea!

@aseemk
Copy link
Author

aseemk commented May 11, 2012

Cool, contacted GitHub support and they fixed it!

@gasi
Copy link

gasi commented May 12, 2012

Cool! Now I don’t have to miss out on all your gems :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment