-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update dependencies, split files and switch to kebab-case
- Loading branch information
Showing
9 changed files
with
113 additions
and
71 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
File renamed without changes.
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,25 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Check if extension ist correct | ||
* | ||
* @param {string} path | ||
* @param {array} extensions | ||
* @returns extension of file | ||
*/ | ||
exports.checkExtension = (path, extensions) => | ||
extensions.indexOf(path.substring(path.length, path.lastIndexOf('.'))) >= 0; | ||
|
||
/** | ||
* Get filename without extension | ||
* | ||
* @param {string} path | ||
* @returns filename | ||
*/ | ||
exports.getFilename = path => | ||
(path && | ||
path | ||
.split('/') | ||
.pop() | ||
.substring(0, path.lastIndexOf('.'))) || | ||
''; |
File renamed without changes.
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
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,19 @@ | ||
'use strict'; | ||
|
||
const { checkExtension, getFilename } = require('../helpers/utils'); | ||
|
||
describe('test utils', () => { | ||
test('checkExtension should return true', () => { | ||
expect(checkExtension('./dir/test.jpg', ['.jpg'])).toBe(true); | ||
}); | ||
test('checkExtension should return false', () => { | ||
expect(checkExtension('test.jpg', ['.vue'])).toBe(false); | ||
}); | ||
test('getFilename should return only filename', () => { | ||
expect(getFilename('../path/to/test-file.js')).toBe('test-file.js'); | ||
}); | ||
test('getFilename should return empty string', () => { | ||
expect(getFilename(undefined)).toBe(''); | ||
expect(getFilename()).toBe(''); | ||
}); | ||
}); |
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