Why the folder plugins is on default .gitignore?

Hi guys!

I know that node_modules and platforms does not need to be inside git but I think that the plugins folder should be.

Am I wrong? There is a way to work with cordova plugins like we work with node modules? Putting them in a package folder and specify the version so everyone can install it the same version?

Each plugin does have a good amount of code to it for each platform. So we decided to add it to the gitignore to keep git repos smaller.

Feel free to remove it from the gitignore in your project

1 Like

Just curious and being a bit lazy to test this out … if I were working on an existing Ionic-based project on Github, and the plugins directory wasn’t checked in, how would I know what plugins to add without asking the people that have added plugins?

You could either keep the plugins in the repo, or use a cordova hook to add them.

#!/usr/bin/env node
 
//this hook installs all your plugins
 
// add your plugins to this list--either 
// the identifier, the filesystem location 
// or the URL
var pluginlist = [
    "org.apache.cordova.device",
    "org.apache.cordova.device-motion",
    "org.apache.cordova.device-orientation",
    "org.apache.cordova.geolocation",
    "https://github.com/chrisekelley/AppPreferences/"
];
 
// no need to configure below
 
var fs = require('fs');
var path = require('path');
var sys = require('sys')
var exec = require('child_process').exec;
 
function puts(error, stdout, stderr) {
    sys.puts(stdout)
}
 
pluginlist.forEach(function(plug) {
    exec("cordova plugin add " + plug, puts);
});

You would just edit the hook to include the plugins you need. Also, hooks can be executed during multiple points in the cordova process.

1 Like

Thanks! I’ve added it to before_build/ in hooks/.

you can save the plugins in your config.xml file, for example:

cordova plugin add git_url --save

Regards, Nicholls