GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - HogaStack/py-node-manager: A tool library for conveniently using Node.js in Python

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
py_node_manager
py_node_manager
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README-zh_CN.md
README-zh_CN.md
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
pytest.ini
pytest.ini
 
 
requirements-dev.txt
requirements-dev.txt
 
 
ruff.toml
ruff.toml
 
 

Repository files navigation

py-node-manager

A tool library for conveniently using Node.js in Python.

Tests Coverage GitHub PyPI Ruff

English | 简体中文

Installation

pip install py-node-manager

Usage

Basic Usage

from py_node_manager import NodeManager

# Create NodeManager instance
# download_node=True means automatically download Node.js if not found in system
# node_version specifies the Node.js version to download
manager = NodeManager(download_node=True, node_version='18.17.0')

# Get paths to Node.js, npm, and npx
node_path = manager.node_path  # Path to downloaded Node.js, None if using system Node.js
npm_path = manager.npm_path    # Path to npm
npx_path = manager.npx_path    # Path to npx

# Get environment variables (if using downloaded Node.js)
node_env = manager.node_env    # Environment variables dictionary

Running Node.js Commands

import subprocess
from py_node_manager import NodeManager

manager = NodeManager(download_node=True, node_version='18.17.0')

# Run Node.js commands
result = subprocess.run(
    [manager.npm_path, 'init', '-y'],
    env=manager.node_env,
    capture_output=True,
    text=True
)
print(result.stdout)

Without Automatic Node.js Download

from py_node_manager import NodeManager

# Will raise an exception if Node.js is not found in the system
manager = NodeManager(download_node=False, node_version='18.17.0')

Testing

This project uses pytest for testing with 100% code coverage.

Running Tests

To run the tests in the conda environment:

# Install dependencies
pip install -e .
pip install -r requirements-dev.txt

# Run tests
pytest tests/ -v

# Run tests with coverage report
pytest tests/ --cov=py_node_manager --cov-report=term-missing

Test Structure

  • tests/test_node_manager.py - Complete test suite for NodeManager class
  • tests/conftest.py - pytest configuration
  • tests/__init__.py - Package initialization

All code paths are tested including:

  • Normal execution paths
  • Error handling scenarios
  • Platform-specific behaviors
  • CLI mode logging
  • Cached Node.js usage

About

A tool library for conveniently using Node.js in Python

Resources

Readme
MIT license
Activity
Custom properties

Stars

3 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.