Last active
August 29, 2015 14:06
-
-
Save hparra/9c4de5fcc0073c628376 to your computer and use it in GitHub Desktop.
Add "import Ember from 'ember';" to the top of each file that jshint says needs it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# See http://www.ember-cli.com/#using-modules | |
# Assumes your ember JS is in app/js/ | |
# | |
# TODO: | |
# - make ember js src directory a variable | |
# - make error to search for variable | |
# - make replacement string variable | |
# - abstract into function | |
# | |
# Assumes GNU sed, which is not on Mac OS X. `brew install gnu-sed` and use `gsed` instead | |
SED=sed | |
# | |
# Add "import DS from 'ember-data';" to the top of each file JSHint complains about | |
# | |
jshint app/js/ | # Run JSHint | |
$SED -e "s=\(app/js/.*.js\).*'DS' is not defined.$=\1=" -e 'tx' -e 'd' -e ':x' | # Replace lines with only path when object is not define, delete others | |
uniq | # Remove duplicates | |
xargs $SED -i "1iimport DS from 'ember-data';" # Prepend line to each file | |
# | |
# Add "import Ember from 'ember';" to the top of each file JSHint complains about | |
# | |
jshint app/js/ | # Run JSHint | |
$SED -e "s=\(app/js/.*.js\).*'Ember' is not defined.$=\1=" -e 'tx' -e 'd' -e ':x' | # Replace lines with only path when object is not define, delete others | |
uniq | # Remove duplicates | |
xargs $SED -i "1iimport Ember from 'ember';" # Prepend line to each file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment