@pony-ci/sfdx-node
v1.0.4
Published
Execute sfdx commands in node.
Downloads
17
Maintainers
Readme
sfdx-node
Execute sfdx commands in node.
The sfdx-cli itself doesn't have to be installed.
Usage
All commands are asynchronous.
// run tests
await sfdx.force.apex.test.run({targetusername: 'username'});
// set default username
await sfdx.force.config.set({}, 'defaultusername=username');
// set global default username
await sfdx.force.config.set({global: true}, 'defaultusername=username');
// suppress stdout and stderr
await sfdx.force.config.set({quiet: true}, 'defaultusername=username');
SFDX Plugins
This module includes the force
plugin by default.
You can override this plugin with a different version or even add support for other plugins.
To add or override plugin, add node module containing the commands into dependencies in your package.json
file.
Then register the commands using registerNamespace
function.
// override force plugin
const FORCE_PATH = path.dirname(require.resolve('salesforce-alm'));
registerNamespace({
commandsDir: path.join(FORCE_PATH, 'commands'),
namespace: 'force'
});
// add custom plugin
const PLUGIN_PATH = path.dirname(require.resolve('my-plugin-module'));
registerNamespace({
commandsDir: path.join(PLUGIN_PATH, 'commands'),
namespace: 'namespace'
});
Requirements for plugins.
- Commands must be in the
<commandsDir>/<namespace>/
directory. - Each command file must contain one of the following:
- default export of a class extending
SfdxCommand
- export of a class extending the ToolbeltCommand and its name must be in camel case,
without namespace name and with
Command
suffix, e.g.OrgCreateCommand
forforce/org/create.js
file whereforce
is a namespace.
- default export of a class extending
Even some first versions of force commands don't fulfil these requirements.
License
This software is released under the MIT License.