Skip to content

Commit

Permalink
feat(format): add * format option
Browse files Browse the repository at this point in the history
Preserves source formatting
  • Loading branch information
CaryLandholt committed Jun 14, 2014
1 parent ee70d19 commit dcc2029
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -641,6 +641,7 @@ The content that may contain CoffeeScript classes to convert to AngularJS module

#### options
Type: `Object`
Default: `undefined`


##### options.appName
Expand Down Expand Up @@ -710,6 +711,7 @@ Default: `{format: 'camelCase'}`
### Supported Formats
Format | Example
--- | ---
* | *no change*
camelCase | camelCase
lowerCamelCase | lowerCamelCase
lowerCase | lowercase
Expand Down
3 changes: 3 additions & 0 deletions lib/changeCase.coffee
@@ -1,6 +1,9 @@
caseChangeRegEx = /([a-z\d])([A-Z])/g

module.exports = (input, caseFormat) ->
return if caseFormat is '*'
input

return if caseFormat in ['camelCase', 'lowerCamelCase']
input[0].toLowerCase() + input[1..]

Expand Down
14 changes: 14 additions & 0 deletions test/changeCase.spec.coffee
@@ -1,6 +1,20 @@
changeCase = require '../lib/changeCase'

describe 'formatOptions', ->
it 'should not change the source casing', ->
format = '*'
input = 'myInput'
result = changeCase input, format
expectation = 'myInput'

expect(result).toEqual(expectation)

input = 'MyInput'
result = changeCase input, format
expectation = 'MyInput'

expect(result).toEqual(expectation)

it 'should change to camelCase', ->
format = 'camelCase'
input = 'myInput'
Expand Down

0 comments on commit dcc2029

Please sign in to comment.