Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Nodeenv changelog
Version [unreleased]
--------------------

- The default configuration dump and README example omit options without
defaults, such as `mirror`, so they can be copied into a config file
without selecting a mirror named `None`
`#422 <https://github.com/ekalinin/nodeenv/issues/422>`_
- Require Python 3.10 or later, matching the minimum version tested in CI.
Update package classifiers and wheel tags, and remove the unused Python 2
compatibility paths. Old Node.js source builds still require Python 2.7
Expand Down Expand Up @@ -35,8 +39,8 @@ Version [unreleased]
text files (npm 8) and whose workspaces are missing (npm >= 9); the default
`--npm=latest` no longer ends in a 404 there
`#310 <https://github.com/ekalinin/nodeenv/issues/310>`_
- Quoted values in the config file, as the README shows them, are read
without the quotes, and `user:password@` in the `--mirror` URL is sent to
- Quoted values in the config file are read without the quotes, and
`user:password@` in the `--mirror` URL is sent to
the mirror with HTTP Basic authentication instead of being taken for a part
of the host; the password stays out of error messages and redirects
`#321 <https://github.com/ekalinin/nodeenv/issues/321>`_
Expand Down
13 changes: 8 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -480,22 +480,25 @@ the keys in that file are the long command-line option names.
These are the available options and their defaults::

[nodeenv]
node = 'latest'
npm = 'latest'
node = latest
npm = latest
with_npm = False
jobs = '2'
jobs = 2
without_ssl = False
debug = False
profile = False
make = 'make'
make = make
prebuilt = True
ignore_ssl_certs = False
with_certifi = False
mirror = None
prefer_system = False
isolate_npm = False
clean_src = True

Options without a default, such as ``mirror``, can be omitted. Do not use
``mirror = None``: INI values are strings, so that would select a mirror
named ``None`` instead of using nodeenv's default download source.

Alternatives
------------

Expand Down
2 changes: 1 addition & 1 deletion nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _dump(cls):
print(" [nodeenv]")
print(" " + "\n ".join(
"%s = %s" % (k, v) for k, v in sorted(vars(cls).items())
if not k.startswith('_')))
if not k.startswith('_') and v is not None))


Config._default = dict(
Expand Down
34 changes: 34 additions & 0 deletions tests/test_config_dump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import re

import pytest

import nodeenv


@pytest.fixture
def default_config(monkeypatch, tmpdir):
for name, value in nodeenv.Config._default.items():
monkeypatch.setattr(nodeenv.Config, name, value)
monkeypatch.chdir(str(tmpdir))


def _load_defaults(text, tmpdir):
config = tmpdir.join('nodeenvrc')
config.write(text)
nodeenv.Config._load([str(config)])
assert {name: getattr(nodeenv.Config, name)
for name in nodeenv.Config._default} == nodeenv.Config._default


def test_dumped_configuration_roundtrips(default_config, capsys, tmpdir):
nodeenv.Config._dump()
_load_defaults(capsys.readouterr().out, tmpdir)


def test_readme_configuration_roundtrips(default_config, tmpdir):
readme = os.path.join(os.path.dirname(__file__), '..', 'README.rst')
with open(readme) as stream:
block = re.search(r' \[nodeenv\]\n(?: .*\n)+',
stream.read()).group(0)
_load_defaults('\n'.join(line[4:] for line in block.splitlines()), tmpdir)
Loading