Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SantoshSrinivas79/6c7957a75ff36d792e5575e89e80329b to your computer and use it in GitHub Desktop.
Save SantoshSrinivas79/6c7957a75ff36d792e5575e89e80329b to your computer and use it in GitHub Desktop.
Create scaffolder for a meteor collection

Meteor Scaffolder

  • Get list of files required
find . -type f -name '*ghost*.js'
rm -rf ~/temp/scaffolder
mkdir -p ~/temp/scaffolder

Copy all .js files and replace ghost with unicorn

IMPORTANT:

On OSX ... replace sed with gsed (Credit: https://stackoverflow.com/questions/17534840/sed-throws-bad-flag-in-substitute-command)

bash

rm -rf scaffolder
tree scaffolder

mkdir -p scaffolder

find . -type f -name '*ghost*.js' | while IFS= read -r f; do 
    echo $f
    f=${f//.\//};
    echo $f
    echo $(dirname "scaffolder/$f")
    dirPath=$(dirname "scaffolder/$f")
    echo $dirPath

    fname=`basename $f`
    echo $fname
    echo ${fname//ghost/unicorn}
    newName=${fname//ghost/unicorn}
    echo $newName

    mkdir -p $(dirname "scaffolder/$f")
    
    cp $f $dirPath/$newName
    sed -i 's/ghost/unicorn/g' $dirPath/$newName
    sed -i 's/Ghost/Unicorn/g' $dirPath/$newName
done

tree scaffolder

Copy all .html files and replace ghost with unicorn

tree scaffolder

mkdir -p scaffolder

find . -type f -name '*ghost*.html' | while IFS= read -r f; do 
    echo $f
    f=${f//.\//};
    echo $f
    echo $(dirname "scaffolder/$f")
    dirPath=$(dirname "scaffolder/$f")
    echo $dirPath

    fname=`basename $f`
    echo $fname
    echo ${fname//ghost/unicorn}
    newName=${fname//ghost/unicorn}
    echo $newName

    mkdir -p $(dirname "scaffolder/$f")
    
    cp $f $dirPath/$newName
    sed -i 's/ghost/unicorn/g' $dirPath/$newName
    sed -i 's/Ghost/Unicorn/g' $dirPath/$newName
done

tree scaffolder

rsync -av scaffolder/* .

rm -rf scaffolder/

That's it! Da shit rocks!

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