Managing Dependencies¶
Once you’ve run your generators, you’ll often want to run pip to install any additional dependencies your generators require.
As these tasks are very frequent, Banana already abstracts them away. We’ll also cover how you can launch installation through other tools.
Note that Banana provided installation helpers will automatically schedule the installation to run once as part of the install queue. If you need to run anything after they’ve run, use the end queue.
pip¶
TODO
You just need to call generator.pipInstall() to run an pip installation. Banana will ensure the pip install command is only run once even if it is called multiple times by multiple generators.
For example you want to install lodash as a dev dependency:
class extends Generator {
installingLodash() {
this.pipInstall(['lodash'], { 'save-dev': true });
}
}
This is equivalent to call:
pip install lodash --save-dev
on the command line in your project.
Using other tools¶
TODO
Banana provides an abstraction to allow users to spawn any CLI commands. This abstraction will normalize to command so it can run seamlessly in Linux, Mac and Windows system.
For example, if you’re a PHP aficionado and wished to run composer, you’d write it this way:
class extends Generator {
install() {
this.spawnCommand('composer', ['install']);
}
}
Make sure to call the spawnCommand method inside the install queue. Your users don’t want to wait for an installation command to complete.