scripts/install/index.js
// Write shell code to hook file
Write shell code to hook file
Write shell code to hook file
function writeCodeToHook(hookPath) {
    backupExistedHook(hookPath);
    let hookCode = getHookShellCode();
    if (!hookCode) {
        log('Failed to get hook code, stop Git hooks installation.', 0);
    }
    try {
        fs.writeFileSync(hookPath, hookCode);
    } catch (e) {
        log('Failed to create hook files in .git/hooks folder, error message is:');
        console.log(e.message);
    }
    try {
        fs.chmodSync(hookPath, '777');
    } catch (e) {
        log('Failed to chmod 777 for hook files, error message is:');
        console.log(e.message);
    }
}
function writeCodeToHook ( hookPath ) { backupExistedHook ( hookPath ) ; let hookCode = getHookShellCode ( ) ; if ( ! hookCode ) { log ( 'Failed to get hook code, stop Git hooks installation.' , 0 ) ; } try { fs . writeFileSync ( hookPath , hookCode ) ; } catch ( e ) { log ( 'Failed to create hook files in .git/hooks folder, error message is:' ) ; console . log ( e . message ) ; } try { fs . chmodSync ( hookPath , '777' ) ; } catch ( e ) { log ( 'Failed to chmod 777 for hook files, error message is:' ) ; console . log ( e . message ) ; } }
Write shell code to hook file
Write shell code to hook file
// It could be that we do not have rights to this folder which could cause the // installation of this module to completely fail. We should just output the // error instead destroying the whole npm install process.