-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract getPluginName and toCamelCase to lib-folder (#205)
- Loading branch information
Showing
5 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
|
||
module.exports = function toCamelCase (name) { | ||
if (name[0] === '@') { | ||
name = name.slice(1).replace('/', '-') | ||
} | ||
const newName = name.replace(/-(.)/g, function (match, g1) { | ||
return g1.toUpperCase() | ||
}) | ||
return newName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const toCamelCase = require('../lib/toCamelCase') | ||
|
||
test('from kebab-case to camelCase', (t) => { | ||
t.plan(1) | ||
t.equal(toCamelCase('hello-world'), 'helloWorld') | ||
}) | ||
|
||
test('from @-prefixed named imports', (t) => { | ||
t.plan(1) | ||
t.equal(toCamelCase('@hello/world'), 'helloWorld') | ||
}) | ||
|
||
test('from @-prefixed named kebab-case to camelCase', (t) => { | ||
t.plan(1) | ||
t.equal(toCamelCase('@hello/my-world'), 'helloMyWorld') | ||
}) | ||
|
||
test('from kebab-case to camelCase multiple words', (t) => { | ||
t.plan(1) | ||
t.equal(toCamelCase('hello-long-world'), 'helloLongWorld') | ||
}) |