ensure only last occurence of pkg name is replaced

I have a component called ember-typeahead and it was mangling the path for the dependency ember.

for example, it was removing ember from:
```
/Users/paulcowan/projects/ember-typeahead/bower_components/
```
to
```
/Users/paulcowan/projects/-typeahead/bower_components/
```