Skip to content
Permalink
Browse files
Updated to support nopt@^4.0.1
  • Loading branch information
erisu committed Mar 19, 2019
1 parent a9c6305 commit 6b774173093e7b288c95eafd23971f5c0df36ec9
Showing 3 changed files with 17 additions and 8 deletions.
@@ -36,7 +36,7 @@ const known_opts = {
],
project: path,
plugin: [String, path, url, Array],
version: Boolean,
version: String,
help: Boolean,
debug: Boolean,
silent: Boolean,
@@ -45,7 +45,11 @@ const known_opts = {
variable: Array,
www: path,
searchpath: [path, Array],
save: Boolean
save: Boolean,
name: String,
platform_id: String,
platform_version: String,
plugins_dir: String
};
const shortHands = { var: ['--variable'], v: ['--version'], h: ['--help'] };

@@ -28,7 +28,8 @@
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"jasmine": "^3.3.1"
"jasmine": "^3.3.1",
"rewire": "^4.0.1"
},
"bin": {
"plugman": "./main.js"
@@ -16,12 +16,16 @@
specific language governing permissions and limitations
under the License.
*/
var nopt = require('nopt');
const nopt = require('nopt');
const rewire = require('rewire');
const main = rewire('../main');

describe('nopt interface check', () => {
it('parameters without assignment operator should be assigned', () => {
const knownOptions = main.__get__('known_opts');
const shortHands = main.__get__('shortHands');
const cli_opts = nopt(knownOptions, shortHands, ['plugman', 'create', '--name', 'MyName', '--platform_id', 'MyId', '--platform_version', '1.0.0']);

describe('nopt interface check', function () {
// https://issues.apache.org/jira/browse/CB-7915
it('parameters without assignment operator should be assigned', function () {
var cli_opts = nopt(null, null, ['plugman', 'create', '--name', 'MyName', '--platform_id', 'MyId', '--platform_version', '1.0.0']);
expect(cli_opts.name).toEqual('MyName');
expect(cli_opts.platform_id).toEqual('MyId');
expect(cli_opts.platform_version).toEqual('1.0.0');

0 comments on commit 6b77417

Please sign in to comment.