ensure only last occurence of pkg name is replaced

I have a component called ember-typeahead and the line below in ```writePackageFile``` was mangling the path for the dependency ember.
```
  var base = pkg.canonicalDir.replace(pkg.endpoint.name, '');
```
for example, it was removing ember from:
```
/Users/paulcowan/projects/ember-typeahead/bower_components/
```
to
```
/Users/paulcowan/projects/-typeahead/bower_components/
```