Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit f8e86ba

Browse files
authored
chore(contented-processor): pipeline.type to support `^[a-zA-Z_$][\w$]*$ (#706)
#### What this PR does / why we need it: As per title. #### Which issue(s) will this PR fix?:
1 parent 7d381b8 commit f8e86ba

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/contented-processor/src/ContentedProcessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export class ContentedProcessor {
3939
config.outDir = config.outDir ?? './.contented';
4040
config.pipelines.forEach((pipeline) => {
4141
pipeline.type = pipeline.type ?? 'Docs';
42-
if (pipeline.type.match(/[^a-zA-Z]/g)) {
42+
if (!pipeline.type.match(/^[a-zA-Z_$][\w$]*$/)) {
4343
throw new Error(
44-
'Due to codegen, pipeline.type must be a string with allowed characters within the range of [a-zA-Z].',
44+
'Due to codegen, pipeline.type must be a string with allowed characters within the range of ^[a-zA-Z_$][\\w$]*$.',
4545
);
4646
}
4747

packages/contented-processor/src/ContentedProcessor.unit.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,25 @@ describe('validation', () => {
418418
],
419419
};
420420
expect(() => new ContentedProcessor(config)).toThrow(
421-
'Due to codegen, pipeline.type must be a string with allowed characters within the range of [a-zA-Z].',
421+
'Due to codegen, pipeline.type must be a string with allowed characters within the range of ^[a-zA-Z_$][\\w$]*$.',
422422
);
423423
});
424+
425+
it('should allow type.name with _', async () => {
426+
const config: Config = {
427+
rootDir: './fixtures',
428+
outDir: './.contented',
429+
pipelines: [
430+
{
431+
type: '_type',
432+
pattern: '**/*.md',
433+
processor: 'md',
434+
},
435+
],
436+
};
437+
438+
expect(() => new ContentedProcessor(config)).not.toThrow();
439+
});
424440
});
425441

426442
it('should dedup 2 files', async () => {

0 commit comments

Comments
 (0)