Skip to content

Commit f25de4f

Browse files
authored
1 parent 6916ce9 commit f25de4f

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-21
lines changed

lib/decamelize.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
'use strict'
24+
25+
module.exports = (text, separator) => {
26+
separator = typeof separator === 'undefined' ? '_' : separator
27+
28+
return text
29+
.replace(/([a-z\d])([A-Z])/g, `$1${separator}$2`)
30+
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, `$1${separator}$2`)
31+
.toLowerCase()
32+
}

lib/levenshtein.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
/*
22
Copyright (c) 2011 Andrei Mackenzie
33
4-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5-
6-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7-
8-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
this software and associated documentation files (the "Software"), to deal in
6+
the Software without restriction, including without limitation the rights to
7+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
the Software, and to permit persons to whom the Software is furnished to do so,
9+
subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
920
*/
1021

1122
// levenshtein distance algorithm, pulled from Andrei Mackenzie's MIT licensed.

lib/usage.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22
// this file handles outputting usage instructions,
33
// failures, etc. keeps logging in one place.
4+
const decamelize = require('./decamelize')
45
const stringWidth = require('string-width')
56
const objFilter = require('./obj-filter')
67
const path = require('path')
@@ -432,7 +433,7 @@ module.exports = function usage (yargs, y18n) {
432433
}
433434

434435
self.functionDescription = (fn) => {
435-
const description = fn.name ? require('decamelize')(fn.name, '-') : __('generated-value')
436+
const description = fn.name ? decamelize(fn.name, '-') : __('generated-value')
436437
return ['(', description, ')'].join('')
437438
}
438439

package.json

+14-15
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,31 @@
1919
],
2020
"dependencies": {
2121
"cliui": "^4.0.0",
22-
"decamelize": "^1.2.0",
2322
"find-up": "^3.0.0",
24-
"get-caller-file": "^1.0.1",
23+
"get-caller-file": "^2.0.1",
2524
"os-locale": "^3.1.0",
2625
"require-directory": "^2.1.1",
27-
"require-main-filename": "^1.0.1",
26+
"require-main-filename": "^2.0.0",
2827
"set-blocking": "^2.0.0",
29-
"string-width": "^2.0.0",
28+
"string-width": "^3.0.0",
3029
"which-module": "^2.0.0",
31-
"y18n": "^3.2.1 || ^4.0.0",
32-
"yargs-parser": "^11.1.1"
30+
"y18n": "^4.0.0",
31+
"yargs-parser": "^12.0.0"
3332
},
3433
"devDependencies": {
35-
"chai": "^4.1.2",
36-
"chalk": "^1.1.3",
34+
"chai": "^4.2.0",
35+
"chalk": "^2.4.2",
3736
"coveralls": "^3.0.2",
38-
"cpr": "^2.0.0",
37+
"cpr": "^3.0.1",
3938
"cross-spawn": "^6.0.4",
40-
"es6-promise": "^4.0.2",
39+
"es6-promise": "^4.2.5",
4140
"hashish": "0.0.4",
42-
"mocha": "^5.1.1",
43-
"nyc": "^11.7.3",
44-
"rimraf": "^2.5.0",
41+
"mocha": "^5.2.0",
42+
"nyc": "^13.2.0",
43+
"rimraf": "^2.6.3",
4544
"standard": "^11.0.1",
46-
"standard-version": "^4.2.0",
47-
"which": "^1.2.9",
45+
"standard-version": "^4.4.0",
46+
"which": "^1.3.1",
4847
"yargs-test-extends": "^1.0.1"
4948
},
5049
"scripts": {

0 commit comments

Comments
 (0)