Skip to content

Commit

Permalink
Implement new option
Browse files Browse the repository at this point in the history
  • Loading branch information
calumapplepie committed Jul 5, 2020
1 parent 03e06fd commit 60eb741
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions npm2deb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def __init__(self, module_name=None, args={}):
self.debian_debhelper = args['debhelper']
if 'noclean' in args:
self.noclean = args['noclean']
if 'noregistry' in args:
self.noregistry = args['noregistry']
if 'no_registry' in args:
self.noregistry = args['no_registry']
self.noclean = True #I don't know if this is needed, doing it for safety

self.read_package_info()
Expand Down Expand Up @@ -418,14 +418,24 @@ def read_package_info(self):
self._get_json_version()
self._get_json_license()

def download(self):
def download_tarball(self):
utils.debug(1, "downloading %s@%s tarball from npm registry" % (self.name, self.version))
info = _getstatusoutput('npm pack "%s@%s"' % (self.name, self.version))
if info[0] is not 0:
exception = "Error downloading package %s@%s\n" % (self.name, self.version)
exception += info[1]
raise ValueError(exception)
tarball_file = info[1].split('\n')[-1]
extract_tarball(tarball_file)

def given_tarball(self)
utils.debug(1, "opening %s tarball" % (self.name))
tarball_file = self.name;
extract_tarball(tarball_file)


def extract_tarball(self, tarball_file):
utils.debug(2,"extracting tarball....")
tarball = tarfile.open(tarball_file)
# get the root directory name
root_dir = tarball.getnames()[0]
Expand All @@ -438,7 +448,8 @@ def download(self):
tarball.close()

# remove tarball file
_os.remove(tarball_file)
if not self.noclean
_os.remove(tarball_file)

if root_dir is not self.debian_name:
utils.debug(2, "renaming %s to %s" % (root_dir, self.debian_name))
Expand Down
4 changes: 2 additions & 2 deletions npm2deb/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def main(argv=None):
'-v', '--version', action='version', version='%(prog)s ' + _.VERSION)

parser.add_argument(
'--noRegistry',
'--no-registry',
action="store_true",
default=False,
help='Use a local tarball in NPM format instead of downloading. Implies -n')
help='Use a local tarball downloading one with NPM.')

This comment has been minimized.

Copy link
@pravi

pravi Jul 8, 2020

Contributor

instead of downloading (missed instead of)

This comment has been minimized.

Copy link
@calumapplepie

calumapplepie Jul 9, 2020

Author

How I managed to have that in one commit and not in the next is beyond me.


subparsers = parser.add_subparsers(title='commands')

Expand Down

0 comments on commit 60eb741

Please sign in to comment.