1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | function getModuleName(filePath) {
|
13 |
|
14 |
|
15 | var filename = require("path").basename(filePath, require("path").extname(filePath));
|
16 |
|
17 |
|
18 | filename = filename.replace(/(?:\.\w+)+/, '');
|
19 |
|
20 | var moduleName = filename === 'index' ? require("path").basename(require("path").dirname(filePath)) : filename;
|
21 |
|
22 |
|
23 | moduleName = moduleName.replace(/(?:\.\w+)+/, '');
|
24 |
|
25 |
|
26 | moduleName = moduleName.replace(/[^a-zA-Z0-9]+(\w?)/g, function (match, next) {
|
27 | return next.toUpperCase();
|
28 | });
|
29 | return moduleName;
|
30 | }
|
31 |
|
32 | module.exports = getModuleName; |
\ | No newline at end of file |