@travetto/manifest 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/module.ts +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
package/src/module.ts CHANGED
@@ -26,6 +26,17 @@ const INDEX_FILES = new Set(
26
26
  const STD_TOP_FOLDERS = new Set(['src', 'bin', 'support']);
27
27
  const STD_TOP_FILES = new Set([...INDEX_FILES, 'package.json']);
28
28
 
29
+ const SUPPORT_FILE_MAP: Record<string, ManifestModuleRole> = {
30
+ transformer: 'compile',
31
+ compile: 'compile',
32
+ test: 'test',
33
+ doc: 'doc',
34
+ pack: 'build',
35
+ FILEld: 'build'
36
+ };
37
+
38
+ const SUPPORT_FILE_RE = new RegExp(`^support[/](?<name>${Object.keys(SUPPORT_FILE_MAP).join('|')})[./]`);
39
+
29
40
  export class ManifestModuleUtil {
30
41
 
31
42
  static #scanCache: Record<string, string[]> = {};
@@ -121,9 +132,10 @@ export class ManifestModuleUtil {
121
132
  * Get file type for a file name
122
133
  */
123
134
  static getFileRole(moduleFile: string): ManifestModuleRole | undefined {
124
- if (moduleFile.startsWith('support/transform')) {
125
- return 'compile';
126
- } else if (moduleFile.startsWith('support/test/') || moduleFile.startsWith('test/')) {
135
+ const matched = SUPPORT_FILE_MAP[moduleFile.match(SUPPORT_FILE_RE)?.groups?.name ?? ''];
136
+ if (matched) {
137
+ return matched;
138
+ } else if (moduleFile.startsWith('test/')) {
127
139
  return 'test';
128
140
  } else if (moduleFile.startsWith('doc/') || /^DOC[.]tsx?$/.test(moduleFile)) {
129
141
  return 'doc';
@@ -144,7 +156,7 @@ export class ManifestModuleUtil {
144
156
  return 'support/fixtures';
145
157
  } else if (moduleFile.startsWith('support/resources/')) {
146
158
  return 'support/resources';
147
- } else if (moduleFile.startsWith('support/transform')) {
159
+ } else if (/^support\/transformer[./]/.test(moduleFile)) {
148
160
  return '$transformer';
149
161
  }
150
162
  const key = moduleFile.substring(0, folderLocation);