Skip to content

Repository files navigation

static-npm

Runs npm, npx and node through lazy fetched binary downloads. Cross-platform: Windows, Linux, MacOsArm, and MacOsx86 supported.

Linting MacOS_Tests MacOSx86_Tests Ubuntu_Tests Win_Tests

Install

pip install static-npm

Cmds

# Get the versions of all tools
static-npm --version
static-node --version
static-npx --version

# Install live-server
static-npm install -g live-server

# Install and run in isolated environment.
static-npm-tool live-server --port=1234

Example: Install npm live-server and use it

# NpmTool handle downloading and running a npm based tool installed in isolation.
import time
from static_npm import NpmTool
live_server = NpmTool("live-server").run([f"--port=8888"])
# Web browser should pop up.
time.sleep(10)
live_server.kill()

Api

from pathlib import Path
from static_npm.npm import Npm
from static_npm.npx import Npx
from static_npm.paths import CACHE_DIR

def _get_tool_dir(tool: str) -> Path:
    return CACHE_DIR / tool

npm = Npm()
npx = Npx()
tool_dir = _get_tool_dir("live-server")
npm.run(["install", "live-server", "--prefix", str(tool_dir)])
proc = npx.run(["live-server", "--version", "--prefix", str(tool_dir)])
rtn = proc.wait()
stdout = proc.stdout
assert 0 == rtn
assert "live-server" in stdout

To develop software, run . ./activate.sh

Windows

This environment requires you to use git-bash.

Linting

Run ./lint.sh to find linting errors using pylint, flake8 and mypy.

About

Runs npm, npx and node through lazy-fetched binaries. Windows, Linux, macOS arm + x86.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages