010_install_plugins.js 933 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env node
  2. /**
  3. * Install all plugins listed in package.json
  4. * https://raw.githubusercontent.com/diegonetto/generator-ionic/master/templates/hooks/after_platform_add/install_plugins.js
  5. */
  6. var exec = require('child_process').exec;
  7. var path = require('path');
  8. var sys = require('sys');
  9. var packageJSON = null;
  10. try {
  11. packageJSON = require('../../package.json');
  12. } catch(ex) {
  13. console.log('\nThere was an error fetching your package.json file.')
  14. console.log('\nPlease ensure a valid package.json is in the root of this project\n')
  15. return;
  16. }
  17. var cmd = process.platform === 'win32' ? 'cordova.cmd' : 'cordova';
  18. // var script = path.resolve(__dirname, '../../node_modules/cordova/bin', cmd);
  19. packageJSON.cordovaPlugins = packageJSON.cordovaPlugins || [];
  20. packageJSON.cordovaPlugins.forEach(function (plugin) {
  21. exec('cordova plugin add ' + plugin, function (error, stdout, stderr) {
  22. sys.puts(stdout);
  23. });
  24. });