Skip to main content
Glama
build_npm_bin.py1.46 kB
#!/usr/bin/env python3 """ Builds a portable, standalone npm binary. """ import argparse import os import stat if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "--bin-out-path", help="Path to output binary script", ) parser.add_argument( "--package-dir", help="Path to the workspace member package", ) parser.add_argument( "node_modules", help="Path to `node_modules`", ) parser.add_argument( "bin", help="The binary to create from `node_modules`", ) args = parser.parse_args() bins_path = os.path.abspath(args.node_modules) if args.package_dir: bins_path = os.path.join( bins_path, args.package_dir, "node_modules", ".bin", ) else: bins_path = os.path.join( bins_path, "node_modules", ".bin", ) bin = os.path.join(bins_path, args.bin) path = [bins_path] content = [ "#!/usr/bin/env sh", "export PATH=\"{}:$PATH\"".format(":".join(path)), "exec {} $@".format(bin), ] with open(args.bin_out_path, "w") as f: f.write("\n".join(content)) os.chmod( args.bin_out_path, stat.S_IRUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH, )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server