Skip to content

Commit

Permalink
refactor: better parsing name of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongarc committed Jun 2, 2019
1 parent 7105788 commit 08f2ca6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions register.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function deregisterExtension(extension) {

function registerExtension(extension) {
require.extensions[extension] = function(module, filename) {
const name = path.basename(filename)
.slice(0, -path.extname(filename).length)
const name = path.parse(filename).name
.replace(/^\d/, '_$&')
.replace(/[^a-zA-Z0-9_$]/g, '');

Expand All @@ -46,4 +45,4 @@ function registerExtension(extension) {
registerExtension('.svelte');
registerExtension('.html');

module.exports = register;
module.exports = register;

0 comments on commit 08f2ca6

Please sign in to comment.