Permalink
Browse files

install: prevent a KeyError from being thrown when PORTABLE is not set

  • Loading branch information...
1 parent caf69aa commit 093be8b16bb153d18bfec752d42f8b79a8958800 @TooTallNate committed Aug 6, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 tools/install.py
View
@@ -154,7 +154,7 @@ def npm_files(action):
action([link_path], 'bin/npm')
elif action == install:
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
- if os.environ['PORTABLE']:
+ if os.environ.get('PORTABLE'):
@bnoordhuis

bnoordhuis Aug 6, 2012

if 'PORTABLE' in os.environ:

@bnoordhuis

bnoordhuis Aug 6, 2012

Guess you already landed it.

@TooTallNate

TooTallNate Aug 6, 2012

Owner

What's the difference in this case? (I'm trying to learn this Python thing as I go along ;) )

@bnoordhuis

bnoordhuis Aug 6, 2012

In this case not much but the in operator is considered more pythonic, it returns a bool instead of None and works on more than just dicts.

# This crazy hack is necessary to make the shebang execute the copy
# of node relative to the same directory as the npm script. The precompiled
# binary tarballs use a prefix of "/" which gets translated to "/bin/node"

0 comments on commit 093be8b

Please sign in to comment.