Skip to content

Remove ignore paths from .json #227

Merged
merged 11 commits into from Jan 31, 2013

3 participants

@desandro
Bower member

For #88, this adds ignore property to JSON.

This works by deleting and ignored filepaths after the package has been installed.

Tests added. Note added in the README.

I feel pretty good about this, but I'd appreciate @satazor taking a look at the code.

@satazor satazor commented on an outdated diff Jan 31, 2013
lib/core/package.js
+ var rimrafPaths = function (err) {
+ if (err) return this.emit('error', err);
+ async.forEach(removePaths, function (removePath, next) {
+ // rimraf all the paths
+ rimraf(removePath, function (err) {
+ if (err) return this.emit('error', err);
+ next();
+ }.bind(this));
+ // finished callback
+ }.bind(this), pathsRemoved);
+ }.bind(this);
+
+ // 1: get paths
+ async.forEach(removePatterns, function (removePattern, next) {
+ // glob path for file path pattern matching
+ glob(path.join(this.localPath, removePattern), function (err, globPaths) {
@satazor
Bower member
satazor added a note Jan 31, 2013

I think we must enable the dot: true option so that glob matches the .git and other files that start with a .. If it' s not actually removing the .git folder (wich I think it's not) can you add a test for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@satazor satazor commented on an outdated diff Jan 31, 2013
lib/core/package.js
}.bind(this)).readLocalConfig();
};
+// finish clean up local by removing .git/ and any ignored files
+Package.prototype.removeLocalPaths = function () {
+ var removePatterns = ['.git'];
+ if (this.json.ignore) {
+ removePatterns = removePatterns.concat(this.json.ignore);
@satazor
Bower member
satazor added a note Jan 31, 2013

This could be changed to just: removePatterns.push.apply(removePatterns, this.json.ignore).
Probably faster because no new array is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@satazor
Bower member
satazor commented Jan 31, 2013

Looks great @desandro, please review what I've mentioned.

@desandro
Bower member

Good call for both. Added test for .git directory, and made the push.apply change

@satazor
Bower member
satazor commented Jan 31, 2013

@desandro We still have to turn on the dot option on glob (which will also activate it in the minimatch). Will quote the documentation of minimatch:

dot

Allow patterns to match filenames starting with a period, even if the pattern does not explicitly have a period in that spot.

Note that by default, a/**/b will not match a/.d/b, unless dot is set.

This means that if an user types test/**/* as the ignore pattern and there is a test/.jshintrc file, it won't be ignored unless we use dot: true.

If you add a test for this, it will probably fail.

@SBoudrias

I don't really get the point of asking package creator to "blacklist" unnecessary files. It would be much easier for them to point to the files/directory to be kept. The other way around seems way clearer.

Plus, instead of deleting the downloaded files, you could just keep the full repo copy in the cache, then you copy "whitelisted" files over to the project.

Also, I think this should be over-writable by the end user. So let's say a user want to get twitter bootstrap, but only the modal module, he could easily just pick the file he needs.

@desandro
Bower member

@SBoudrias I totally get your point. This seems backwards. Especially for us to implement. But using ignore is a bit friendlier to package developers. There's already a convention for ignore property. It follows same thinking with .gitignore or npm's ignore.

As for user-overwritability of ignore, let's leave that to another issue in the future.

@desandro
Bower member

Dang, you're good. dot: true option added, which resolves the test cases for dot dirs/files.

@satazor
Bower member
satazor commented Jan 31, 2013

@desandro I know that ahahah :P, joking

Thanks!

@satazor satazor closed this Jan 31, 2013
@satazor satazor reopened this Jan 31, 2013
@satazor satazor merged commit 6195281 into master Jan 31, 2013
@satazor satazor deleted the ignore branch Feb 1, 2013
@samccone samccone referenced this pull request in marionettejs/backbone.marionette May 21, 2014
Closed

Remove clean:tmp #1358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.