diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-12 16:56:26 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-12 16:56:59 +0300 |
| commit | 8b07446f67a5e68d00725fef37061bc87643beb6 (patch) | |
| tree | b5350b11840b808d663e877046e34916c99c81b5 /cli.js | |
| parent | 0b4ebb81270f016bb7e5ed0e95e5e07146c03f0f (diff) | |
Implement installation of NPM packages on host
Diffstat (limited to 'cli.js')
| -rwxr-xr-x | cli.js | 39 |
1 files changed, 33 insertions, 6 deletions
@@ -236,8 +236,8 @@ vorpal } if (!args.key || !args.value) { - this.log('Please provide both "key" and "value" arguments.'); - return callback(); + this.log('Please provide both "key" and "value" arguments.'); + return callback(); } try { @@ -248,7 +248,7 @@ vorpal this.log(chalk.green(`Secret "${args.key}" set successfully.`)); } catch (err) { this.log(chalk.red(`Failed to set secret ${args.key}!`)); - this.log(chalk.red(String(err))); + this.log(chalk.red(String(err))); } callback(); }); @@ -264,8 +264,8 @@ vorpal } if (!args.key) { - this.log('Please provide the "key" argument.'); - return callback(); + this.log('Please provide the "key" argument.'); + return callback(); } try { @@ -273,7 +273,34 @@ vorpal this.log(chalk.green(`Secret "${args.key}" removed successfully.`)); } catch (err) { this.log(chalk.red(`Failed to remove secret ${args.key}!`)); - this.log(chalk.red(String(err))); + this.log(chalk.red(String(err))); + } + callback(); + }); + +vorpal + .command('package install <package>', `Install an NPM package on the host.`) + .action(async function (args, callback) { + try { + await checkConnection(mongoURL, this); + } catch (err) { + showMongoNotSetError(vorpal); + return callback(); + } + + if (!args.package) { + this.log('Please provide the "package" argument.'); + return callback(); + } + + try { + await models.packages.insert({ + name: args.package + }); + this.log(chalk.green(`Package "${args.package}" added successfully to list of packages to install.`)); + } catch (err) { + this.log(chalk.red(`Failed to add package ${args.package} to list of packages to install!`)); + this.log(chalk.red(String(err))); } callback(); }); |
