2014-09-28 16:55:01 -04:00
|
|
|
function file2moduleName(filePath) {
|
2014-11-20 02:57:32 -05:00
|
|
|
return filePath.replace(/\\/g, '/')
|
2014-09-28 16:55:01 -04:00
|
|
|
// module name should be relative to `modules` and `tools` folder
|
|
|
|
.replace(/.*\/modules\//, '')
|
|
|
|
.replace(/.*\/tools\//, '')
|
|
|
|
// module name should not include `src`, `test`, `lib`
|
|
|
|
.replace(/\/src\//, '/')
|
2014-12-05 19:26:30 -05:00
|
|
|
.replace(/\/web\//, '/')
|
|
|
|
.replace(/\/perf_tmp\//, '/')
|
2014-09-28 16:55:01 -04:00
|
|
|
.replace(/\/lib\//, '/')
|
|
|
|
// module name should not have a suffix
|
|
|
|
.replace(/\.\w*$/, '');
|
|
|
|
}
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = file2moduleName;
|
2014-10-06 20:35:00 -04:00
|
|
|
}
|