diff --git a/lib/index.js b/lib/index.js index efe55d3f..8d54d007 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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'; @@ -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; } diff --git a/test/python-plugin.test.js b/test/python-plugin.test.js new file mode 100644 index 00000000..3b7164dc --- /dev/null +++ b/test/python-plugin.test.js @@ -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(); +});