def run_script(script_path: str, cwd: Path | str = '.') -> None:
    """Execute a script from a working directory.

    :param script_path: Absolute path to the script to run.
    :param cwd: The directory to run the script from.
    """
    run_thru_shell = sys.platform.startswith('win')
    if script_path.endswith('.py'):
        script_command = [sys.executable, script_path]
    else:
        script_command = [script_path]

    utils.make_executable(script_path)

    try:
        proc = subprocess.Popen(script_command, shell=run_thru_shell, cwd=cwd)  # nosec
        exit_status = proc.wait()
        if exit_status != EXIT_SUCCESS:
            msg = f'Hook script failed (exit status: {exit_status})'
            raise FailedHookException(msg)
    except OSError as err:
        if err.errno == errno.ENOEXEC:
            msg = 'Hook script failed, might be an empty file or missing a shebang'
            raise FailedHookException(msg) from err
        msg = f'Hook script failed (error: {err})'
        raise FailedHookException(msg) from err
Execute a script from a working directory.

    :param script_path: Absolute path to the script to run.
    :param cwd: The directory to run the script from.
    
cookiecutter/hooks.py