Skip to content

Commit

Permalink
fix: Fall back to config org if no option passed
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 5, 2018
1 parent 20b8ccc commit 99021be
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/protect/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var unsupportedPackageManagers = {
};

function wizard(options = {}) {
options.org = config.org || null;
options.org = options.org || config.org || null;

return processPackageManager(options)
.then(processWizardFlow)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/authorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var request = require('./request');
var config = require('./config');

function actionAllowed(action, options) {
const org = options.org || config.org || null;
return new Promise(function (resolve, reject) {
request({
method: 'GET',
Expand All @@ -11,7 +12,7 @@ function actionAllowed(action, options) {
headers: {
authorization: 'token ' + snyk.api,
},
qs: options.org && {org: options.org},
qs: org && {org},
}, function (error, res, body) {
if (error) {
return reject(error);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/yarn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('then-fs');
const path = require('path');
const lockFileParser = require('snyk-nodejs-lockfile-parser');
const debug = require('debug')('snyk');
const getRuntimeVersion = '../get-node-runtime-version';
const getRuntimeVersion = require('../get-node-runtime-version');

module.exports = {
inspect,
Expand Down
10 changes: 6 additions & 4 deletions src/lib/snyk-test/common.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const config = require('../config');

module.exports.assembleQueryString = function (options) {
var qs = {};
if (options.org) {
qs.org = options.org;
}
const org = options.org || config.org || null;
const qs = {
org,
};

if (options.severityThreshold) {
qs.severityThreshold = options.severityThreshold;
}
Expand Down

0 comments on commit 99021be

Please sign in to comment.