Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Python 3.3+, replace pipes.quote with shlex.quote #342

Merged
merged 2 commits into from
May 28, 2024
Merged
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
13 changes: 8 additions & 5 deletions nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import argparse
import subprocess
import tarfile
import pipes
if sys.version_info < (3, 3):
from pipes import quote as _quote
else:
from shlex import quote as _quote
import platform
import zipfile
import shutil
Expand Down Expand Up @@ -728,7 +731,7 @@ def build_node_from_src(env_dir, src_dir, node_src_dir, args):

conf_cmd = [
'./configure',
'--prefix=%s' % pipes.quote(env_dir)
'--prefix=%s' % _quote(env_dir)
]
if args.without_ssl:
conf_cmd.append('--without-ssl')
Expand Down Expand Up @@ -810,7 +813,7 @@ def install_npm(env_dir, _src_dir, args):
(
'bash', '-c',
'. {0} && npm install -g npm@{1}'.format(
pipes.quote(join(env_dir, 'bin', 'activate')),
_quote(join(env_dir, 'bin', 'activate')),
args.npm,
)
),
Expand Down Expand Up @@ -878,10 +881,10 @@ def install_packages(env_dir, args):
activate_path = join(env_dir, 'bin', 'activate')
real_npm_ver = args.npm if args.npm.count(".") == 2 else args.npm + ".0"
if args.npm == "latest" or real_npm_ver >= "1.0.0":
cmd = '. ' + pipes.quote(activate_path) + \
cmd = '. ' + _quote(activate_path) + \
' && npm install -g %(pack)s'
else:
cmd = '. ' + pipes.quote(activate_path) + \
cmd = '. ' + _quote(activate_path) + \
' && npm install %(pack)s' + \
' && npm activate %(pack)s'

Expand Down
9 changes: 6 additions & 3 deletions tests/nodeenv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from __future__ import unicode_literals

import os.path
import pipes
if sys.version_info < (3, 3):
from pipes import quote as _quote
else:
from shlex import quote as _quote
import subprocess
import sys
import sysconfig
Expand All @@ -29,7 +32,7 @@ def test_smoke(tmpdir):
'-m', 'nodeenv', '--prebuilt', nenv_path,
])
assert os.path.exists(nenv_path)
activate = pipes.quote(os.path.join(nenv_path, 'bin', 'activate'))
activate = _quote(os.path.join(nenv_path, 'bin', 'activate'))
subprocess.check_call([
'sh', '-c', '. {} && node --version'.format(activate),
])
Expand All @@ -44,7 +47,7 @@ def test_smoke_n_system_special_chars(tmpdir):
'-m', 'nodeenv', '-n', 'system', nenv_path,
))
assert os.path.exists(nenv_path)
activate = pipes.quote(os.path.join(nenv_path, 'bin', 'activate'))
activate = _quote(os.path.join(nenv_path, 'bin', 'activate'))
subprocess.check_call([
'sh', '-c', '. {} && node --version'.format(activate),
])
Expand Down
Loading