diff --git a/_gulp/modules/gulpfileSections.test.ts b/_gulp/modules/gulpfileSections.test.ts new file mode 100644 index 0000000..257374a --- /dev/null +++ b/_gulp/modules/gulpfileSections.test.ts @@ -0,0 +1,33 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { markupSection } from '../templates/gulpfile/sections'; +import { createGulpTemplateContext } from '../templates/gulpfile/types'; + +test('markupSection includes pug compilation when markup is Pug', () => { + const context = createGulpTemplateContext({ + script: 'JavaScript', + style: 'Sass', + markup: 'Pug', + addNormalize: false, + addReset: false, + }); + + const output = markupSection(context); + + assert.match(output, /\.pipe\(pug\(\)\)/); +}); + +test('markupSection does not inject pug compilation when markup is HTML', () => { + const context = createGulpTemplateContext({ + script: 'TypeScript', + style: 'SCSS', + markup: 'HTML', + addNormalize: true, + addReset: true, + }); + + const output = markupSection(context); + + assert.doesNotMatch(output, /\.pipe\(pug\(\)\)/); + assert.match(output, /\.pipe\(plumber\(\)\)\n\s*\.pipe\(dest\('dist'\)\)/); +}); diff --git a/_gulp/templates/gulpfile/sections.ts b/_gulp/templates/gulpfile/sections.ts index 7120936..a36e598 100644 --- a/_gulp/templates/gulpfile/sections.ts +++ b/_gulp/templates/gulpfile/sections.ts @@ -69,10 +69,11 @@ export function scriptsSection({ choices, scriptFolder, scriptExtension }: GulpT } export function markupSection({ choices, markupFolder, markupExtension }: GulpTemplateContext): string { + const compileMarkupPipe = choices.markup === 'Pug' ? '\n .pipe(pug())' : ''; + return `function markup() { return src('src/${markupFolder}/**/*.${markupExtension}') - .pipe(plumber()) - ${choices.markup === 'Pug' ? '.pipe(pug())' : ''} + .pipe(plumber())${compileMarkupPipe} .pipe(dest('dist')); }`; }