@Kureev Kureev released this Jan 20, 2016 · 109 commits to master since this release

It was quite some time ago that we released a 1.3.5. We'd like to compensate this lack of releases by adding a new nice feature that will help developers to ship even more awesome rnpm plugins:


Commands is a new rnpm feature for managing user interactions. From 1.4.0 version you can use something similar to npm's scripts for running a shell commands / external scripts in your plugin's runtime. Let me show you an example:

Can we do it better? Oh yes, now we can!

By using a new rnpm commands feature, we introduced a new functionality for our rnpm-plugin-link users. Now, if you're using rnpm-plugin-link, you can make a custom prelink / postlink commands to run your custom scripts in a queue. For instance, in this particular case with GA token, a custom script may looks like this:

Content of react-native-google-analytics-bridge's package.json:

"rnpm": {
  "commands": {
    "postlink": "./bin/requireGAToken"

Now, every time user will try to link a react-native-google-analytics-bridge module, rnpm-plugin-link will run a postlink hook, which will require a user to input his personal GA token to finish linking.

What is inside the ./bin/requireGAToken file?

const inquirer = require('inquirer');

  message: 'Please, insert here your GA token:',
  name: 'GAToken'
}], (answers) => {
  // Do something with answers.GAToken
  // For instance, you can patch your MainActivity.java to fill a required token!

As you can see, it's a simple javascript file using inquirer to poll a user for some required information.

I hope, this example gave you some insights into how commands supposed to work.

Note: We're spawning a new processes for your commands. At the same moment we're blocking our main thread until commands would be executed. That means you don't need to worry about handling async operations inside your commands. Yay!