Skip to content

Commit 4d4113c

Browse files
army8735dead-horse
authored andcommitted
style(core): beautify reg and add .idea to ignore (#179)
Use `sets` instead of `or` in reg is clearer to be understand. `.idea` is created by the series of IDE which developed by JetBrains.
1 parent e43c708 commit 4d4113c

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ npm-debug.log
66
.DS_Store
77
yarn.lock
88
test/fixtures/egg/node_modules/egg-core
9+
.idea

lib/loader/file_loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class FileLoader {
153153
// app/service/foo/bar.js => [ 'foo', 'bar' ]
154154
const properties = getProperties(filepath, this.options);
155155
// app/service/foo/bar.js => service.foo.bar
156-
const pathName = directory.split(/\/|\\/).slice(-1) + '.' + properties.join('.');
156+
const pathName = directory.split(/[/\\]/).slice(-1) + '.' + properties.join('.');
157157
// get exports from the file
158158
const exports = getExports(fullpath, this.options, pathName);
159159

lib/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
},
7676

7777
getResolvedFilename(filepath, baseDir) {
78-
const reg = /\\|\//g;
78+
const reg = /[/\\]/g;
7979
return filepath.replace(baseDir + path.sep, '').replace(reg, '/');
8080
},
8181
};

0 commit comments

Comments
 (0)