Apache cordova

Clone this repo:
  1. b779a34 refactor(PluginInfo): cleanup & simplify (#132) by Raphael von der Grün · 3 weeks ago master
  2. 6f922c0 refactor(misc): cleanup & simplify (#131) by Raphael von der Grün · 3 weeks ago
  3. 5f245f0 refactor(ConfigChanges): simplify (#130) by Raphael von der Grün · 3 weeks ago
  4. 4b03d3d refactor(xml-helpers): DRY & simplify (#128) by Raphael von der Grün · 3 weeks ago
  5. 0a94812 fix: broken lock file from #95 (#129) by Raphael von der Grün · 3 weeks ago

Build status Build Status NPM


Exposes shared functionality used by cordova-lib and Cordova platforms.

Exposed APIs


Represents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli


var events = require('cordova-common').events;
events.emit('warn', 'Some warning message')

There are the following events supported by cordova-cli: verbose, log, info, warn, error.


An error class used by Cordova to throw cordova-specific errors. The CordovaError class is inherited from Error, so CordovaError instances is also valid Error instances (instanceof check succeeds).


var CordovaError = require('cordova-common').CordovaError;
throw new CordovaError('Some error message', SOME_ERR_CODE);

See CordovaError for supported error codes.


Exposes functionality to deal with cordova project config.xml files. For ConfigParser API reference check ConfigParser Readme.


var ConfigParser = require('cordova-common').ConfigParser;
var appConfig = new ConfigParser('path/to/cordova-app/config.xml');
console.log(appconfig.name() + ':' + appConfig.version());

PluginInfoProvider and PluginInfo

PluginInfo is a wrapper for cordova plugins' plugin.xml files. This class may be instantiated directly or via PluginInfoProvider. The difference is that PluginInfoProvider caches PluginInfo instances based on plugin source directory.


var PluginInfo: require('cordova-common').PluginInfo;
var PluginInfoProvider: require('cordova-common').PluginInfoProvider;

// The following instances are equal
var plugin1 = new PluginInfo('path/to/plugin_directory');
var plugin2 = new PluginInfoProvider().get('path/to/plugin_directory');

console.log('The plugin ' + plugin1.id + ' has version ' + plugin1.version)


Utility module for dealing with sequential tasks. Provides a set of tasks that are needed to be done and reverts all tasks that are already completed if one of those tasks fail to complete. Used internally by cordova-lib and platform's plugin installation routines.


var ActionStack = require('cordova-common').ActionStack;
var stack = new ActionStack()

var action1 = stack.createAction(task1, [<task parameters>], task1_reverter, [<reverter_parameters>]);
var action2 = stack.createAction(task2, [<task parameters>], task2_reverter, [<reverter_parameters>]);


.then(function() {
    // all actions succeded
    // One of actions failed with error


Module for spawning child processes with some advanced logic.


var superspawn = require('cordova-common').superspawn;
superspawn.spawn('adb', ['devices'])
    if (data.stderr)
        console.error('"adb devices" raised an error: ' + data.stderr);
    // Do something...


A set of utility methods for dealing with XML files.


var xml = require('cordova-common').xmlHelpers;

var xmlDoc1 = xml.parseElementtreeSync('some/xml/file');
var xmlDoc2 = xml.parseElementtreeSync('another/xml/file');

xml.mergeXml(doc1, doc2); // doc2 now contains all the nodes from doc1

Other APIs

The APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines.



  • Clone this repository onto your local machine git clone https://github.com/apache/cordova-common.git
  • Navigate to cordova-common directory, install dependencies and npm-link cd cordova-common && npm install && npm link
  • Navigate to cordova-lib directory and link cordova-common cd <cordova-lib directory> && npm link cordova-common && npm install