Skip to content

Commit

Permalink
Remove args[0] from being passed into the command
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed May 1, 2018
1 parent 0f3bfcd commit b31d461
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = function(args, opts = {}) {

if (!command) return;

command.run({ args, opts });
command.run({ args: args.slice(1), opts });
};
6 changes: 3 additions & 3 deletions lib/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function defaultCallback(err) {
return process.exit();
}

exports.run = function(info, cb = defaultCallback) {
const [apiKey, id] = info.opts.token.split('-');
exports.run = function({ args, opts }, cb = defaultCallback) {
const [apiKey, id] = opts.token.split('-');

function callback(err, response, data) {
if (err) return cb(err);
Expand All @@ -34,7 +34,7 @@ exports.run = function(info, cb = defaultCallback) {

const options = {
formData: {
swagger: fs.createReadStream(path.resolve(process.cwd(), info.args[1])),
swagger: fs.createReadStream(path.resolve(process.cwd(), args[0])),
},
auth: { user: apiKey },
};
Expand Down
4 changes: 2 additions & 2 deletions test/swagger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('swagger command', () => {
.reply(201);

swagger.run(
{ args: ['swagger', './test/fixtures/swagger.json'], opts: { token: apiKey } },
{ args: ['./test/fixtures/swagger.json'], opts: { token: apiKey } },
err => {
if (err) return done(err);
mock.done();
Expand All @@ -34,7 +34,7 @@ describe('swagger command', () => {

swagger.run(
{
args: ['swagger', './test/fixtures/swagger.json'],
args: ['./test/fixtures/swagger.json'],
opts: { token: `${apiKey}-${id}` },
},
err => {
Expand Down

0 comments on commit b31d461

Please sign in to comment.