src/hooks/HooksRunner.js
function runScriptViaChildProcessSpawn(script, context) {
    var opts = context.opts;
    var command = script.fullPath;
    var args = [opts.projectRoot];

    if (fs.statSync(script.fullPath).isDirectory()) {
        events.emit('verbose', 'Skipped directory "' + script.fullPath + '" within hook directory');
        return Q();
    }

    if (isWindows) {
        // TODO: Make shebang sniffing a setting (not everyone will want this).
        var interpreter = extractSheBangInterpreter(script.fullPath);
        // we have shebang, so try to run this script using correct interpreter
        if (interpreter) {
            args.unshift(command);
            command = interpreter;
        }
    }

    var execOpts = {cwd: opts.projectRoot, printCommand: true, stdio: 'inherit'};
    execOpts.env = {};
    execOpts.env.CORDOVA_VERSION = require('../../package').version;
    execOpts.env.CORDOVA_PLATFORMS = opts.platforms ? opts.platforms.join() : '';
    execOpts.env.CORDOVA_PLUGINS = opts.plugins ? opts.plugins.join() : '';
    execOpts.env.CORDOVA_HOOK = script.fullPath;
    execOpts.env.CORDOVA_CMDLINE = process.argv.join(' ');

    return superspawn.spawn(command, args, execOpts)
        .catch(function(err) {
            // Don't treat non-executable files as errors. They could be READMEs, or Windows-only scripts.
            if (!isWindows && err.code == 'EACCES') {
                events.emit('verbose', 'Skipped non-executable file: ' + script.fullPath);
            } else {
                throw new Error('Hook failed with error code ' + err.code + ': ' + script.fullPath);
            }
        });
}
function runScriptViaChildProcessSpawn(script, context) {
    var opts = context.opts;
    var command = script.fullPath;
    var args = [opts.projectRoot];

    if (fs.statSync(script.fullPath).isDirectory()) {
        events.emit('verbose', 'Skipped directory "' + script.fullPath + '" within hook directory');
        return Q();
    }

    if (isWindows) {
        // TODO: Make shebang sniffing a setting (not everyone will want this).
        var interpreter = extractSheBangInterpreter(script.fullPath);
        // we have shebang, so try to run this script using correct interpreter
        if (interpreter) {
            args.unshift(command);
            command = interpreter;
        }
    }

    var execOpts = {cwd: opts.projectRoot, printCommand: true, stdio: 'inherit'};
    execOpts.env = {};
    execOpts.env.CORDOVA_VERSION = require('../../package').version;
    execOpts.env.CORDOVA_PLATFORMS = opts.platforms ? opts.platforms.join() : '';
    execOpts.env.CORDOVA_PLUGINS = opts.plugins ? opts.plugins.join() : '';
    execOpts.env.CORDOVA_HOOK = script.fullPath;
    execOpts.env.CORDOVA_CMDLINE = process.argv.join(' ');

    return superspawn.spawn(command, args, execOpts)
        .catch(function(err) {
            // Don't treat non-executable files as errors. They could be READMEs, or Windows-only scripts.
            if (!isWindows && err.code == 'EACCES') {
                events.emit('verbose', 'Skipped non-executable file: ' + script.fullPath);
            } else {
                throw new Error('Hook failed with error code ' + err.code + ': ' + script.fullPath);
            }
        });
}
function runScriptViaChildProcessSpawn ( script , context ) { var opts = context . opts ; var command = script . fullPath ; var args = [ opts . projectRoot ] ; if ( fs . statSync ( script . fullPath ) . isDirectory ( ) ) { events . emit ( 'verbose' , 'Skipped directory "' + script . fullPath + '" within hook directory' ) ; return Q ( ) ; } if ( isWindows ) { // TODO: Make shebang sniffing a setting (not everyone will want this). var interpreter = extractSheBangInterpreter ( script . fullPath ) ; // we have shebang, so try to run this script using correct interpreter if ( interpreter ) { args . unshift ( command ) ; command = interpreter ; } } var execOpts = { cwd : opts . projectRoot , printCommand : true , stdio : 'inherit' } ; execOpts . env = { } ; execOpts . env . CORDOVA_VERSION = require ( '../../package' ) . version ; execOpts . env . CORDOVA_PLATFORMS = opts . platforms ? opts . platforms . join ( ) : '' ; execOpts . env . CORDOVA_PLUGINS = opts . plugins ? opts . plugins . join ( ) : '' ; execOpts . env . CORDOVA_HOOK = script . fullPath ; execOpts . env . CORDOVA_CMDLINE = process . argv . join ( ' ' ) ; return superspawn . spawn ( command , args , execOpts ) . catch ( function ( err ) { // Don't treat non-executable files as errors. They could be READMEs, or Windows-only scripts. if ( ! isWindows && err . code == 'EACCES' ) { events . emit ( 'verbose' , 'Skipped non-executable file: ' + script . fullPath ) ; } else { throw new Error ( 'Hook failed with error code ' + err . code + ': ' + script . fullPath ) ; } } ) ; }
Runs script using child_process spawn method.
Returns a promise.
Runs script using child_process spawn method . Returns a promise .