Skip to content

Commit

Permalink
feat: supporting args as an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Dror Ben-Gai authored and deebugger committed Oct 18, 2017
1 parent 76fe3ba commit 1fb4f82
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module.exports = {
inspect: inspect,
};

module.exports.__tests = {
buildArgs: buildArgs,
};

function inspect(root, targetFile, options) {
if (!options) { options = {}; }
var command = options.command || 'python';
Expand Down Expand Up @@ -54,6 +58,6 @@ function getDependencies(command, root, targetFile, args) {
function buildArgs(targetFile, extraArgs) {
var args = [path.resolve(__dirname, '../plug/pip_resolve.py')];
if (targetFile) { args.push(targetFile); }
if (extraArgs) { args.push(extraArgs); }
if (extraArgs) { args = args.concat(extraArgs); }
return args;
}
26 changes: 26 additions & 0 deletions test/python-plugin.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var test = require('tap').test;
var plugin = require('../lib').__tests;

test('check build args with array', function (t) {
var result = plugin.buildArgs('requirements.txt', [
'-argOne',
'-argTwo',
]);
t.match(result[0], /.*\/plug\/pip_resolve\.py/);
t.deepEqual(result.slice(1), [
'requirements.txt',
'-argOne',
'-argTwo',
]);
t.end();
});

test('check build args with string', function (t) {
var result = plugin.buildArgs('requirements.txt', '-argOne -argTwo');
t.match(result[0], /.*\/plug\/pip_resolve\.py/);
t.deepEqual(result.slice(1), [
'requirements.txt',
'-argOne -argTwo',
]);
t.end();
});

0 comments on commit 1fb4f82

Please sign in to comment.