Skip to content

Commit

Permalink
add NpmProvider support
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed May 21, 2024
1 parent 6e28c63 commit 1973f88
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pydantic_pkgr/binprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@ def on_install(self, bin_name: str, subdeps: Optional[InstallStr]=None, **contex
print(proc.stderr.strip().decode())
raise Exception(f'{self.__class__.__name__}: install got returncode {proc.returncode} while installing {subdeps}: {subdeps}')

class NpmProvider(BinProvider):
name: BinProviderName = 'npm'

def on_install(self, bin_name: str, subdeps: Optional[InstallStr]=None, **context):
subdeps = subdeps or self.on_get_subdeps(bin_name)
print(f'[*] {self.__class__.__name__}: Installing subdependencies for {bin_name} ({subdeps})')

proc = run(['npm', 'install', '-g', *subdeps.split(' ')], stdout=PIPE, stderr=PIPE)

if proc.returncode != 0:
print(proc.stdout.strip().decode())
print(proc.stderr.strip().decode())
raise Exception(f'{self.__class__.__name__}: install got returncode {proc.returncode} while installing {subdeps}: {subdeps}')


class AptProvider(BinProvider):
name: BinProviderName = 'apt'
Expand Down

0 comments on commit 1973f88

Please sign in to comment.