Skip to content

Commit

Permalink
Merge pull request #232 from asottile/patch-1
Browse files Browse the repository at this point in the history
Fix escape sequences fix
  • Loading branch information
ekalinin authored Feb 19, 2019
2 parents e4c9847 + 63af52f commit 2d41bf8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,19 @@ def to_utf8(text):
if not text or is_PY3:
return text

try: # unicode or pure ascii
try: # unicode or pure ascii
return text.encode("utf8")
except UnicodeDecodeError:
try: # successful UTF-8 decode means it's pretty sure UTF-8
try: # successful UTF-8 decode means it's pretty sure UTF-8
text.decode("utf8")
return text
except UnicodeDecodeError:
try: # get desperate; and yes,
# this has a western hemisphere bias
try: # get desperate; and yes, this has a western hemisphere bias
return text.decode("cp1252").encode("utf8")
except UnicodeDecodeError:
pass

return text # return unchanged, hope for the best
return text # return unchanged, hope for the best


class Config(object):
Expand Down Expand Up @@ -1127,7 +1126,7 @@ def main():
exec __SHIM_NODE__ "$@"
"""

ACTIVATE_BAT = r"""\
ACTIVATE_BAT = r"""
@echo off
set "NODE_VIRTUAL_ENV=__NODE_VIRTUAL_ENV__"
if not defined PROMPT (
Expand Down Expand Up @@ -1173,7 +1172,7 @@ def main():
:END
"""

ACTIVATE_PS1 = r"""\
ACTIVATE_PS1 = r"""
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values
if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
Expand Down Expand Up @@ -1220,7 +1219,7 @@ def main():
$env:PATH = "$env:NODE_VIRTUAL_ENV\Scripts;$env:PATH"
"""

ACTIVATE_SH = r"""\
ACTIVATE_SH = r"""
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
Expand Down

0 comments on commit 2d41bf8

Please # to comment.