Dear Maintainer,
When I try to run:
npm2deb create @babel/parser
the command fails:
...
File "/usr/lib/python3/dist-packages/npm2deb/__init__.py", line 260, in
create_links
orig = _os.path.normpath(self.json['bin'][script])
~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: string indices must be integers, not 'str'
The reason of this error is that:
self.json['bin'] == './bin/babel-parser.js'
in this particular case.
Here is a patch which restores the expected behavior:
-----------------8<-------------------------------------
diff --git a/npm2deb/__init__.py b/npm2deb/__init__.py
index ee3f29a..e2974da 100644
--- a/npm2deb/__init__.py
+++ b/npm2deb/__init__.py
@@ -255,9 +255,16 @@ and may not include tests.\n""")
links = []
dest = self.debian_dest
if 'bin' in self.json:
- for script in self.json['bin']:
- orig = _os.path.normpath(self.json['bin'][script])
- links.append("%s/%s usr/bin/%s" % (dest, orig, script))
+ if isinstance(self.json['bin'], list):
+ for script in self.json['bin']:
+ orig = _os.path.normpath(self.json['bin'][script])
+ links.append("%s/%s /usr/bin/%s" %
+ (self.name, orig, script))
+ else:
+ script = self.json['bin']
+ orig = _os.path.normpath(self.json['bin'])
+ links.append("%s/%s /usr/bin/%s" %
+ (self.name, orig, script))
if len(links) > 0:
content = '\n'.join(links)
utils.create_debian_file('links', content)
-----------------8<-------------------------------------
Best regards, Georges.