All files / plugins/avenx-vite/src utils.js

89.85% Statements 62/69
100% Branches 16/16
80% Functions 4/5
89.85% Lines 62/69

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 692x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 478x 2x 2x 476x 478x 478x 478x 478x 468x 478x 478x 2x 2x 2x 2x 2x 2x 2x 471x 471x 471x 469x 471x 471x 2x 2x 2x 2x 2x 2x 2x 381x 381x 2x 2x 2x 2x 2x 2x 2x 379x 379x 2x 2x 2x 2x 2x 2x 2x              
import {
  COMPONENT_EXT,
  PAGE_EXT,
  COMPONENT_CSS_EXT,
  PAGE_CSS_EXT,
} from './constants.js';
 
/**
 * Returns true if the file is an Avenx component.
 * @param {string} file
 * @returns {boolean}
 */
export function isComponentFile(file) {
  if (file.endsWith('index.html') || file.includes('index.html?')) {
    return false;
  }
  return (
    file.endsWith(COMPONENT_EXT) ||
    file.endsWith('.component.html') ||
    file.endsWith('.component.avx') ||
    (file.endsWith('.html') && !file.endsWith('.page.html')) ||
    (file.endsWith('.avx') && !file.endsWith('.page.avx'))
  );
}
 
/**
 * Returns true if the file is an Avenx page.
 * @param {string} file
 * @returns {boolean}
 */
export function isPageFile(file) {
  return (
    file.endsWith(PAGE_EXT) ||
    file.endsWith('.page.html') ||
    file.endsWith('.page.avx')
  );
}
 
/**
 * Returns true if the file is an Avenx component stylesheet.
 * @param {string} file
 * @returns {boolean}
 */
export function isComponentStyle(file) {
  return file.endsWith(COMPONENT_CSS_EXT);
}
 
/**
 * Returns true if the file is an Avenx page stylesheet.
 * @param {string} file
 * @returns {boolean}
 */
export function isPageStyle(file) {
  return file.endsWith(PAGE_CSS_EXT);
}
 
/**
 * Returns true if the file is any Avenx source file.
 * @param {string} file
 * @returns {boolean}
 */
export function isAvenxFile(file) {
  return (
    isComponentFile(file) ||
    isPageFile(file) ||
    isComponentStyle(file) ||
    isPageStyle(file)
  );
}