File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ Version [unreleased]
2424 `--source` that is what lets a repeated `--force` build reuse the
2525 downloaded source tree
2626 `#205 <https://github.com/ekalinin/nodeenv/issues/205>`_
27+ - Documented that `--mirror` takes a `file://` URL, so a local directory can
28+ serve as the download source
29+ `#193 <https://github.com/ekalinin/nodeenv/issues/193>`_
2730
2831Version 1.3.1
2932-------------
Original file line number Diff line number Diff line change @@ -141,6 +141,12 @@ Install node.js from a mirror::
141141
142142 $ nodeenv --node=10.19.0 --mirror=https://npm.taobao.org/mirrors/node
143143
144+ A local directory works as a mirror too, if it repeats the layout of
145+ nodejs.org: packages in ``v<version>/ `` and, to resolve ``latest ``, ``lts ``
146+ or a version range, an ``index.json `` next to them::
147+
148+ $ nodeenv --node=22.14.0 --mirror=file:///srv/node-mirror env-22
149+
144150Install the highest node.js release matching a version range::
145151
146152 $ nodeenv --node=22 env-22
@@ -307,7 +313,8 @@ Installation options
307313 Install node.js from the source (Unix only).
308314
309315``--mirror=URL ``
310- Set mirror server of nodejs.org to download from.
316+ Set mirror server of nodejs.org to download from. A ``file:// `` URL
317+ points nodeenv at a local directory instead of a server.
311318
312319``-c, --clean-src ``
313320 Remove "src" directory after installation. This is the default.
Original file line number Diff line number Diff line change 88 from shlex import quote as _quote
99import io
1010import os .path
11+ import pathlib
1112import subprocess
1213import sys
1314import sysconfig
@@ -309,6 +310,20 @@ def rewind(_):
309310 mock_logger .assert_called ()
310311
311312
313+ def test_mirror_option_local_directory (tmpdir ):
314+ """A local directory is a valid mirror, see #193"""
315+ tmpdir .join ('index.json' ).write (
316+ '[{"version": "v99.0.0", "date": "2026-01-01", "lts": false,'
317+ ' "files": ["linux-x64", "linux-x64-musl", "linux-riscv64"]}]' )
318+ mirror = pathlib .Path (str (tmpdir )).as_uri ()
319+ argv = [__file__ , '--list' , '--mirror=' + mirror ]
320+ with mock .patch .object (sys , 'argv' , argv ), \
321+ mock .patch .object (nodeenv .logger , 'info' ) as mock_logger :
322+ nodeenv .src_base_url = None
323+ nodeenv .main ()
324+ mock_logger .assert_called_with ('99.0.0' )
325+
326+
312327@pytest .mark .usefixtures ('mock_index_json' , 'mock_host_platform' )
313328def test_get_latest_node_version ():
314329 assert nodeenv .get_last_stable_node_version () == '13.5.0'
You can’t perform that action at this time.
0 commit comments