File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
'use strict' ;
6
6
7
- const { getFilename, getBasename } = require ( '../utils/filename' ) ;
7
+ const {
8
+ getFilename,
9
+ getBasename,
10
+ getPathFromRepositoryRoot,
11
+ } = require ( '../utils/filename' ) ;
8
12
const {
9
13
checkSettings,
10
14
namingPatternValidator,
@@ -65,13 +69,16 @@ module.exports = {
65
69
return ;
66
70
}
67
71
68
- const filenameWithPath = context . getFilename ( ) ;
69
- const filename = getFilename ( filenameWithPath ) ;
72
+ const pathFromRepositoryRoot = getPathFromRepositoryRoot (
73
+ context . getPhysicalFilename ( ) ,
74
+ context . getCwd ( )
75
+ ) ;
76
+ const filename = getFilename ( pathFromRepositoryRoot ) ;
70
77
71
78
for ( const [ fexPattern , namingPattern ] of Object . entries ( rules ) ) {
72
79
const matchResult =
73
80
matchRule (
74
- filenameWithPath ,
81
+ pathFromRepositoryRoot ,
75
82
fexPattern ,
76
83
getBasename ( filename , ignoreMiddleExtensions ) ,
77
84
namingPattern
Original file line number Diff line number Diff line change @@ -59,10 +59,19 @@ const getSubPaths = (path) => {
59
59
return subPaths ;
60
60
} ;
61
61
62
+ /**
63
+ * @type {string } path from repository root
64
+ * @param {string } fullPath filename with full path
65
+ * @param {string } repositoryRoot path of repository root
66
+ */
67
+ const getPathFromRepositoryRoot = ( fullPath , repositoryRoot ) =>
68
+ fullPath . replace ( `${ repositoryRoot } /` , '' ) ;
69
+
62
70
module . exports = {
63
71
getFolderPath,
64
72
getFilename,
65
73
getBasename,
66
74
getSubPaths,
67
75
getAllFolders,
76
+ getPathFromRepositoryRoot,
68
77
} ;
You can’t perform that action at this time.
0 commit comments