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

84.05% Statements 58/69
100% Branches 13/13
40% Functions 2/5
84.05% Lines 58/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 691x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 1x 1x 7x 8x 8x 8x 8x 2x 8x 8x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 2x 4x 4x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x              
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)
  );
}