const html = require('html-template-tag') const path = require('path') const { forceCovertToBrowserPath } = require('./utils') const webRoot = path.resolve(__dirname, '../../../../../'); const mochaDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha')))) const chaiDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('chai')))) const mochaTeamCityDir = forceCovertToBrowserPath(path.relative(webRoot, path.dirname(require.resolve('mocha-teamcity-reporter')))) /** * Generates HTML templates from list of test sheets */ module.exports = (stylesheets, helpers, spec, less) => { if (!Array.isArray(helpers)) { helpers = [helpers] } return html` Less.js Spec Runner $${stylesheets.map(function(fullLessName) { var pathParts = fullLessName.split('/'); var fullCssName = fullLessName.replace(/less$/, 'css'); // Check if the CSS file exists in the same directory as the LESS file var fs = require('fs'); var cssExists = fs.existsSync(fullCssName); // If not, try the css/ directory for local browser tests if (!cssExists && fullLessName.includes('/test/browser/less/')) { var cssInCssDir = fullLessName.replace('/test/browser/less/', '/test/browser/css/').replace(/less$/, 'css'); if (fs.existsSync(cssInCssDir)) { fullCssName = cssInCssDir; } } var lessName = pathParts[pathParts.length - 1]; var name = lessName.split('.')[0]; return ` ` }).join('')} $${helpers.map(helper => ` `).join('')}
` }