Node.js: Ask for Version before Build


I am using Ionic and I am pretty new to node.js.
I would like to automate the increase of version and build number when using ionic build. The manipulation of the config.xml works (using xml2js). But I’d like to implement a prompt asking for a new version.

Using a prompt in a standalone file works without problems:

var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('Neue Version (leer für weiter, oder x.y.z)> ');
rl.on('line', function(line) { console.log(line); });

If I put the file into the hooks/before_build folder and run ionic build the prompt is shown but the rl.on('line') is never triggered.

Why? Did I miss something?

Thanks in advance!