I am writing TortoiseGIT commit hook which should run nodejs / nodeunit tests and prevent commit if failed.
Below is precommit.bat hook file (pseudo code, NOT WORKING)
  SET RES =  node C:\Work\tests\precommit\precommit.js
  if(RES === false){
    MSG * Some tests failed!
    exit 1
 }
Below is precommit.js which passes callback to customout module for nodeunit (WORKS FINE except process.exit part)
var reporter = require('./customout');
process.chdir(__dirname);
var run_tests = [
    '../unit/HelperTests.js',
    '../unit/coreTests.Logic.js'
];
// Tell the reporter to run the tests
if(run_tests.length > 0) {
    if(arguments[0]){
        console.log("TESTS OK");
        process.exit(0);
    }else{
        console.log("TESTS FAILED");
        process.exit(1);
    }
}
Below is customout.js (WORKS FINE)
exports.run = function (files, options, callback) {
nodeunit.runFiles(paths, {
    testspec: options.testspec,
    testFullSpec: options.testFullSpec,
    moduleStart: function (name) {},
    testDone: function (name, assertions) {
        tracker.remove(name);
        }
    },
    done: function (assertions, end) {
        //passes Boolean to process.exit
        if (callback) callback(
                assertions.failures() ?
                false :
                true)
        );
    },
    testStart: function(name) {
        tracker.put(name);
    }
});
};
What is the proper way to pass true/false from runFiles callback to original Command line process in order to prevent commit and inform user?
 
    