Skip to content

Commit

Permalink
fix: fix regex match
Browse files Browse the repository at this point in the history
  • Loading branch information
teclone committed Jan 30, 2020
1 parent 0964be0 commit 7ead84a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const config: Config = {
/**
* list of asset files to copy over
*/
assets: ['assets/*'],
assets: ['assets/**'],

/**
* boolean indicating if the interop rollup setting should be enabled
Expand Down
24 changes: 19 additions & 5 deletions src/modules/Bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,25 @@ class Bundler {
*/
private resolveRegex(pattern: string | RegExp) {
if (isString(pattern)) {
// match everything
if (pattern === '*') {
return new RegExp('^.*$', 'i');
return new RegExp('^.*', 'i');
} else {
pattern = pattern
.replace(/\./g, '\\.')
.replace(/\*{2}/g, '.*')
.replace(/\*/g, '[^/]+');
return new RegExp('^' + pattern + '$', 'i');
.split('/')
.map(current => {
if (current === '*') {
return '[^/]+';
} else if (current === '**') {
return '.*';
} else {
return current;
}
})
.join('/');

pattern = pattern.replace(/^\/+/, '^');
return new RegExp(pattern, 'i');
}
} else {
return pattern;
Expand Down Expand Up @@ -238,6 +249,9 @@ class Bundler {
const isTypeDefinitionFile = ext === '.d.ts';
const isAssetFile = !isTypeDefinitionFile && !isBuildFile;

if (isAssetFile) {
console.log(config.assets);
}
src = oldRelativePath;
if (isTypeDefinitionFile && config.cjsConfig.enabled) {
result.typeDefinitionFiles.push(current);
Expand Down

0 comments on commit 7ead84a

Please sign in to comment.