I'm having a cordova project running in Visual Studio. Before the build process I want to use the hook functionality in order to copy an additional gradle file to the corresponding platforms folder. For copying this file I'm using a simple javascript file. I want to use js because it is independent of the OS.
I use the following code from here:
source = "D:\\myProject\\config\\build-extras.gradle";
target = "D:\\myProject\\platforms\\android\\build-extras.gradle";
var fs = require('fs');
var cbCalled = false;
var rd = fs.createReadStream(source);
rd.on("error", function(err) {
done(err);
});
var wr = fs.createWriteStream(target);
wr.on("error", function(err) {
done(err);
});
wr.on("close", function(ex) {
done();
});
rd.pipe(wr);
function done(err) {
if (!cbCalled) {
console.log("Something wrong with copy of build-extras.gradle: " + err);
cbCalled = true;
}
}
When I run this code in a console with node, then the script is copying the file as expected. However, when I include the same script in my config.xml file of cordova the script is doing something different: It creates a file with the defined name but the file is always empty. Does anybody know what's wrong here?
Thanks, Peter