src/hooks/HooksRunner.js
function runScriptViaModuleLoader(script, context) {
    if(!fs.existsSync(script.fullPath)) {
        events.emit('warn', 'Script file does\'t exist and will be skipped: ' + script.fullPath);
        return Q();
    }
    var scriptFn = require(script.fullPath);
    context.scriptLocation = script.fullPath;
    context.opts.plugin = script.plugin;

    // We can't run script if it is a plain Node script - it will run its commands when we require it.
    // This is not a desired case as we want to pass context, but added for compatibility.
    if (scriptFn instanceof Function) {
        // If hook is async it can return promise instance and we will handle it.
        return Q(scriptFn(context));
    } else {
        return Q();
    }
}
function runScriptViaModuleLoader(script, context) {
    if(!fs.existsSync(script.fullPath)) {
        events.emit('warn', 'Script file does\'t exist and will be skipped: ' + script.fullPath);
        return Q();
    }
    var scriptFn = require(script.fullPath);
    context.scriptLocation = script.fullPath;
    context.opts.plugin = script.plugin;

    // We can't run script if it is a plain Node script - it will run its commands when we require it.
    // This is not a desired case as we want to pass context, but added for compatibility.
    if (scriptFn instanceof Function) {
        // If hook is async it can return promise instance and we will handle it.
        return Q(scriptFn(context));
    } else {
        return Q();
    }
}
function runScriptViaModuleLoader ( script , context ) { if ( ! fs . existsSync ( script . fullPath ) ) { events . emit ( 'warn' , 'Script file does\'t exist and will be skipped: ' + script . fullPath ) ; return Q ( ) ; } var scriptFn = require ( script . fullPath ) ; context . scriptLocation = script . fullPath ; context . opts . plugin = script . plugin ; // We can't run script if it is a plain Node script - it will run its commands when we require it. // This is not a desired case as we want to pass context, but added for compatibility. if ( scriptFn instanceof Function ) { // If hook is async it can return promise instance and we will handle it. return Q ( scriptFn ( context ) ) ; } else { return Q ( ) ; } }
Runs script using require.
Returns a promise.
Runs script using require . Returns a promise .