[Pkg-javascript-commits] [node-dargs] 35/54: Close #27 PR: tweaks.

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-dargs.

commit 0ed0c6f4bca3df2fe12b95a4e5a5fa05e2d444c6
Author: Sam Verschueren <sam.verschueren at gmail.com>
Date:   Sun Dec 27 17:09:24 2015 +0100

    Close #27 PR: tweaks.
---
 .jshintrc    | 13 -------------
 .travis.yml  |  2 +-
 index.js     | 12 +++++-------
 package.json |  5 +++--
 readme.md    |  8 ++++----
 test.js      | 52 ++++++++++++++++++----------------------------------
 6 files changed, 31 insertions(+), 61 deletions(-)

diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 804f8af..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,13 +0,0 @@
-{
-	"node": true,
-	"esnext": true,
-	"bitwise": true,
-	"camelcase": true,
-	"curly": true,
-	"immed": true,
-	"newcap": true,
-	"noarg": true,
-	"undef": true,
-	"unused": "vars",
-	"strict": true
-}
diff --git a/.travis.yml b/.travis.yml
index dedfc07..52ba159 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
 sudo: false
 language: node_js
 node_js:
-  - 'iojs'
+  - 'stable'
   - '0.12'
   - '0.10'
diff --git a/index.js b/index.js
index 7539fe8..a7f9a8c 100644
--- a/index.js
+++ b/index.js
@@ -4,13 +4,11 @@ var numberIsNan = require('number-is-nan');
 function createArg(key, val) {
 	key = key.replace(/[A-Z]/g, '-$&').toLowerCase();
 	return '--' + key + (val ? '=' + val : '');
-};
+}
 
-function match(arr, value){
-	return arr.some(function(toMatch) {
-		return toMatch instanceof RegExp
-			? toMatch.test(value)
-			: toMatch === value;
+function match(arr, val) {
+	return arr.some(function (x) {
+		return x instanceof RegExp ? x.test(val) : x === val;
 	});
 }
 
@@ -43,7 +41,7 @@ module.exports = function (input, opts) {
 		}
 
 		if (typeof val === 'number' && !numberIsNan(val)) {
-			args.push(createArg(key, '' + val));
+			args.push(createArg(key, String(val)));
 		}
 
 		if (Array.isArray(val)) {
diff --git a/package.json b/package.json
index da01e49..1c98c0f 100644
--- a/package.json
+++ b/package.json
@@ -31,14 +31,15 @@
     "url": "sindresorhus.com"
   },
   "scripts": {
-    "test": "node test.js"
+    "test": "xo && ava"
   },
   "dependencies": {
     "number-is-nan": "^1.0.0"
   },
   "devDependencies": {
     "array-equal": "^1.0.0",
-    "ava": "^0.0.4"
+    "ava": "*",
+    "xo": "*"
   },
   "engines": {
     "node": ">=0.10.0"
diff --git a/readme.md b/readme.md
index 5af5ab7..d32deac 100644
--- a/readme.md
+++ b/readme.md
@@ -15,9 +15,9 @@ $ npm install --save dargs
 #### Usage
 
 ```js
-var dargs = require('dargs');
+const dargs = require('dargs');
 
-var input = {
+const input = {
 	foo: 'bar',
 	hello: true,                    // results in only the key being used
 	cake: false,                    // prepends `no-` before the key
@@ -27,8 +27,8 @@ var input = {
 	sad: ':('
 };
 
-var excludes = ['sad', /.*Kind$/];  // excludes and includes accept regular expressions
-var includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
+const excludes = ['sad', /.*Kind$/];  // excludes and includes accept regular expressions
+const includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
 
 console.log(dargs(input, {excludes: excludes}));
 /*
diff --git a/test.js b/test.js
index 98416b4..a2dad51 100644
--- a/test.js
+++ b/test.js
@@ -1,9 +1,7 @@
-'use strict';
-var deepEqual = require('array-equal');
-var test = require('ava');
-var dargs = require('./');
+import test from 'ava';
+import fn from './';
 
-var fixture = {
+const fixture = {
 	a: 'foo',
 	b: true,
 	c: false,
@@ -16,9 +14,8 @@ var fixture = {
 	camelCaseCamel: true
 };
 
-test('convert options to cli flags', function (t) {
-	var actual = dargs(fixture);
-	var expected = [
+test('convert options to cli flags', t => {
+	t.same(fn(fixture), [
 		'--a=foo',
 		'--b',
 		'--no-c',
@@ -28,54 +25,41 @@ test('convert options to cli flags', function (t) {
 		'--h=with a space',
 		'--i=let\'s try quotes',
 		'--camel-case-camel'
-	];
-	t.assert(deepEqual(actual, expected));
-	t.end();
+	]);
 });
 
-test('exclude options', function (t) {
-	var actual = dargs(fixture, {excludes: ['b', /^e$/, 'h', 'i']});
-	var expected = [
+test('exclude options', t => {
+	t.same(fn(fixture, {excludes: ['b', /^e$/, 'h', 'i']}), [
 		'--a=foo',
 		'--no-c',
 		'--d=5',
 		'--camel-case-camel'
-	];
-	t.assert(deepEqual(actual, expected));
-	t.end();
+	]);
 });
 
-test('includes options', function (t) {
-	var actual = dargs(fixture, {includes: ['a', 'c', 'd', 'e', /^camelCase.*/]});
-	var expected = [
+test('includes options', t => {
+	t.same(fn(fixture, {includes: ['a', 'c', 'd', 'e', /^camelCase.*/]}), [
 		'--a=foo',
 		'--no-c',
 		'--d=5',
 		'--e=foo',
 		'--e=bar',
 		'--camel-case-camel'
-	];
-	t.assert(deepEqual(actual, expected));
-	t.end();
+	]);
 });
 
-test('excludes and includes options', function (t) {
-	var actual = dargs(fixture, {
+test('excludes and includes options', t => {
+	t.same(fn(fixture, {
 		excludes: ['a', 'd'],
 		includes: ['a', 'c', /^[de]$/, 'camelCaseCamel']
-	});
-	var expected = [
+	}), [
 		'--no-c',
 		'--e=foo',
 		'--e=bar',
 		'--camel-case-camel'
-	];
-	t.assert(deepEqual(actual, expected));
-	t.end();
+	]);
 });
 
-test('option to ignore false values', function (t) {
-	var actual = dargs({foo: false}, {ignoreFalse: true});
-	t.assert(deepEqual(actual, []));
-	t.end();
+test('option to ignore false values', t => {
+	t.same(fn({foo: false}, {ignoreFalse: true}), []);
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-dargs.git



More information about the Pkg-javascript-commits mailing list