diff options
author | Zara Zaimeche <zara.zaimeche@codethink.co.uk> | 2015-01-09 13:33:24 +0000 |
---|---|---|
committer | Zara Zaimeche <zara.zaimeche@codethink.co.uk> | 2015-01-09 14:43:23 +0000 |
commit | 1405026325c64c3e314d1cde9dfda404dc04140d (patch) | |
tree | 194c1cb94c3b8c877353545ba74b1dd4b29afe18 /baserockimport/app.py | |
parent | 6005fe40376d4edef0db5bfd5a80e553d5d05a96 (diff) | |
download | import-1405026325c64c3e314d1cde9dfda404dc04140d.tar.gz |
Add npm subcommand to import tool via app.py
Diffstat (limited to 'baserockimport/app.py')
-rw-r--r-- | baserockimport/app.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/baserockimport/app.py b/baserockimport/app.py index 2ab2c87..cd3203e 100644 --- a/baserockimport/app.py +++ b/baserockimport/app.py @@ -78,6 +78,8 @@ class BaserockImportApplication(cliapp.Application): return False def setup(self): + self.add_subcommand('npm', self.import_npm, + arg_synopsis='PACKAGE [VERSION]') self.add_subcommand('omnibus', self.import_omnibus, arg_synopsis='REPO PROJECT_NAME SOFTWARE_NAME') self.add_subcommand('rubygems', self.import_rubygems, @@ -170,6 +172,22 @@ class BaserockImportApplication(cliapp.Application): loop.enable_importer('rubygems') loop.run() + def import_npm(self, args): + '''Import one or more Node.js npm packages.''' + if len(args) not in [1, 2]: + raise cliapp.AppException( + 'Please pass the name and version of an npm package on the ' + 'commandline.') + + goal_name = args[0] + goal_version = args[1] if len(args) == 2 else 'master' + + loop = baserockimport.mainloop.ImportLoop( + app=self, + goal_kind='npm', goal_name=goal_name, goal_version=goal_version) + loop.enable_importer('npm', strata=['strata/nodejs.morph']) + loop.run() + def import_rubygems(self, args): '''Import one or more RubyGems.''' if len(args) not in [1, 2]: |