From 983eb63718dbfd96bcf740ac4185d8e578cedfd6 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 4 Nov 2024 04:49:47 +0000 Subject: [PATCH] Build: Add support for "module" link on QUnit pages (#108) First released with QUnit 3.0.0-alpha.4. Ref https://github.com/qunitjs/qunit/pull/1798. Ref https://github.com/qunitjs/qunit/issues/1551. --- Gruntfile.js | 12 +++++++++--- templates/qunit-release.hbs | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 030696aa..bb749bff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -311,12 +311,18 @@ grunt.registerTask( "build-index", function() { } function getQunitData() { - var files = grunt.file.expand( "cdn/qunit/*.js" ), - releases = parseReleases( files, - /(qunit\/qunit-(\d+\.\d+\.\d+(?:[A-z-]+\.\d+)?)(?:\.(min))?\.js)$/ ); + const files = grunt.file.expand( "cdn/qunit/*.js" ); + const releases = parseReleases( + files, + /(qunit\/qunit-(\d+\.\d+\.\d+(?:[A-z-]+\.\d+)?)(?:\.(min))?\.js)$/ + ); releases.forEach( function( release ) { release.theme = release.filename.replace( ".js", ".css" ); + const moduleFilename = release.filename.replace( ".js", ".module.js" ); + if ( files.includes( "cdn/" + moduleFilename ) ) { + release.module = moduleFilename; + } } ); return { diff --git a/templates/qunit-release.hbs b/templates/qunit-release.hbs index 9858baf9..75951138 100644 --- a/templates/qunit-release.hbs +++ b/templates/qunit-release.hbs @@ -1,5 +1,6 @@
  • QUnit {{version}} - - {{cdnSriLink filename "script"}}, + {{cdnSriLink filename "script"}},{{#if module}} + {{cdnSriLink module "module"}},{{/if}} {{cdnLink theme "stylesheet"}}