import os
import subprocess
import sys
import shutil


def ensure_node():
    if not shutil.which("node"):
        print("starnose requires Node.js.")
        print("install: https://nodejs.org")
        sys.exit(1)


def main():
    ensure_node()
    args = sys.argv[1:]
    result = subprocess.run(
        ["npx", "--yes", "snose"] + args,
        env={**os.environ},
    )
    sys.exit(result.returncode)
