[Build] Tons of improvements

This commit is contained in:
2025-03-25 19:51:37 +01:00
parent c53069f0df
commit bab328c2d3
3 changed files with 132 additions and 26 deletions

40
build/util.js Normal file
View File

@@ -0,0 +1,40 @@
const convert = require( 'color-convert' );
/**
* Recursively find all HTML files in a directory
* @param {string} dir The directory to search. Either absolute or relative path
* @param {string} extension The file extension to look for
* @returns {string[]} returns a list of html files with their full path
*/
const treeWalker = ( dir, extension ) => {
const ls = fs.readdirSync( dir );
const fileList = [];
for ( let file in ls ) {
if ( !ls[ file ].includes( '.' ) ) {
const newFiles = treeWalker( dir + '/' + ls[ file ], extension );
for ( let file in newFiles ) {
fileList.push( newFiles[ file ] );
}
} else if ( extension == '*' ) {
fileList.push( dir + '/' + ls[ file ] );
} else if ( ls[ file ].includes( extension ) ) {
fileList.push( dir + '/' + ls[ file ] );
}
}
return fileList;
}
const renderColourAsHex = ( colour ) => {
return '#' + convert.default.rgb.hex( colour[ 0 ], colour[ 1 ], colour[ 2 ] );
}
const renderColourAsRGB = ( colour ) => {
return `rgb( ${ colour[ 0 ] }, ${ colour[ 1 ] }, ${ colour[ 2 ] } )`
}
module.exports = {
treeWalker,
renderColourAsHex,
renderColourAsRGB
}