pajtai / grunt-build-gh-pages

Grunt task to take build directory from current task and move it to another branch
MIT License
13 stars 4 forks source link

Exclude special folders a part from node_modules #2

Closed andresgutgon closed 11 years ago

andresgutgon commented 11 years ago

Reading this again. image

Now I understand why you are excluding.

But what happend if in development I´m working with Bower? https://github.com/bower/bower

Which is a pakage management system for Front-End libraries.

Bower generates a folder with all the packages. And is excluded from my repository. And I would like to maintain bettwen deploys.

Could you add a config param to add more directories like bower generated? It would be great.

pajtai commented 11 years ago

Would adding bower to .gitignore solve the problem?

andresgutgon commented 11 years ago

I think it dosn´t. bower works the same way that node_modules. In place of package.json you have a component.json. And with bower install the dependencies. This dependencies are not necessary for production if you have a build script. The people that colaborate in the project can run a bower command to install these dependencies.

I think is good idea for this project let people exclude custom folders. But is only an idea :)

pajtai commented 11 years ago

The reason I was asking about adding bower to .gitignore is that if you did that it would be preserved between builds, and it wouldn't be committed to the gh-pages branch with git add -A. The important thing is that it has to be in the .gitignore of both branches (your current branch & your build branch). Not sure how else I would implement an exclude.

andresgutgon commented 11 years ago

Sorry. Maybe I´m missing something. But you avoid remove node_modules to avoid reinstall again. Right? If I include bower folder in both .gitignore a won´t avoid that this plugin delete the folder if is not included here:

'ls | grep -v ^' + options.dist + '$ | grep -v ^node_modules$ | xargs rm -r '

This is right?

Maybe you could pass here another option:

      options: {
        dist: 'dist',
        build_branch: 'gh-pages',
        pull: true,
        dont_remove: 'bower_folder, another_folder, one-file.js'
      },

And then generate in the plugin with underscore a string with the grep expresion:

Example:

var dont_remove = 'bower_folder, another_folder, one-file.js';

dont_remove = dont_remove.split(',');
dont_remove = ' | ' + _.map(dont_remove, function(folder){ 
    var clean_folder = folder.trim();
    return 'grep -v ^' + clean_folder + '$'; 
}).join(' | ');

console.log(dont_remove);

Here the live example: http://jsfiddle.net/v8c3k/

image

pajtai commented 11 years ago

Yeah, you're right. It has to be in .gitignore and it has to be part of the grep -v ....

I do like the idea of passing in additional excluded directories. I'd probably make it an array of excluded files strings instead of one big string, so you could just iterate over dont_remove = ['bower', 'other'].... not sure if using minmatch would be necessary.

I'll add this at some point, or if you want send a pull request.

andresgutgon commented 11 years ago

Great!. Thanks :) Yes, better an array. More easy to implement.

What you mean with minmatch?

pajtai commented 11 years ago

@andresgutgon - I added this in and did a quick test. Let me know if it works for you. Thanks, Peter. The new option is exclude.

andresgutgon commented 11 years ago

Great!. Thanks :+1: I'll try it