| commit | a4216009e7bc7c18bccaff1bf8091d7c72b72aea | [log] [tgz] |
|---|---|---|
| author | Audrey So <audreyso@apache.org> | Fri Aug 25 11:52:42 2017 -0700 |
| committer | Audrey So <audreyso@apache.org> | Fri Aug 25 11:52:42 2017 -0700 |
| tree | 4b9b5e864174adcf5afc62358ab7758dabd67575 | |
| parent | 3af9a17c92578194284698a358d7a5e84cfa0e30 [diff] | |
| parent | 7f38f6b266e683f56eb7ca980fe9fdff405b5f35 [diff] |
Merge branch 'CB-13145' of https://github.com/stevengill/cordova-common into CB-13145-steve
Expoeses shared functionality used by cordova-lib and Cordova platforms.
eventsRepresents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli
Usage:
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.
CordovaErrorAn 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).
Usage:
var CordovaError = require('cordova-common').CordovaError; throw new CordovaError('Some error message', SOME_ERR_CODE);
See CordovaError for supported error codes.
ConfigParserExposes functionality to deal with cordova project config.xml files. For ConfigParser API reference check ConfigParser Readme.
Usage:
var ConfigParser = require('cordova-common').ConfigParser; var appConfig = new ConfigParser('path/to/cordova-app/config.xml'); console.log(appconfig.name() + ':' + appConfig.version());
PluginInfoProvider and PluginInfoPluginInfo 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.
Usage:
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)
ActionStackUtility 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.
Usage:
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>]); stack.push(action1); stack.push(action2); stack.process() .then(function() { // all actions succeded }) .catch(function(error){ // One of actions failed with error })
superspawnModule for spawning child processes with some advanced logic.
Usage:
var superspawn = require('cordova-common').superspawn; superspawn.spawn('adb', ['devices']) .progress(function(data){ if (data.stderr) console.error('"adb devices" raised an error: ' + data.stderr); }) .then(function(devices){ // Do something... })
xmlHelpersA set of utility methods for dealing with xml files.
Usage:
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
The APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines.
PlatformJson ConfigChanges ConfigKeeper ConfigFile mungeUtil
git clone https://git-wip-us.apache.org/repos/asf/cordova-lib.gitcd cordova-lib/cordova-commonnpm install && npm linkcd ../cordova-lib && npm link cordova-common && npm install