Reformat assets.js code
This commit is contained in:
parent
2aaaa71d85
commit
aeac56c95d
|
@ -40,20 +40,20 @@ function checkAssetFileName(inputFilename) {
|
||||||
// Recursive function to get files
|
// Recursive function to get files
|
||||||
function getFiles(dir, files = []) {
|
function getFiles(dir, files = []) {
|
||||||
// Get an array of all files and directories in the passed directory using fs.readdirSync
|
// Get an array of all files and directories in the passed directory using fs.readdirSync
|
||||||
const fileList = fs.readdirSync(dir)
|
const fileList = fs.readdirSync(dir);
|
||||||
// Create the full path of the file/directory by concatenating the passed directory and file/directory name
|
// Create the full path of the file/directory by concatenating the passed directory and file/directory name
|
||||||
for (const file of fileList) {
|
for (const file of fileList) {
|
||||||
const name = `${dir}/${file}`
|
const name = `${dir}/${file}`;
|
||||||
// Check if the current file/directory is a directory using fs.statSync
|
// Check if the current file/directory is a directory using fs.statSync
|
||||||
if (fs.statSync(name).isDirectory()) {
|
if (fs.statSync(name).isDirectory()) {
|
||||||
// If it is a directory, recursively call the getFiles function with the directory path and the files array
|
// If it is a directory, recursively call the getFiles function with the directory path and the files array
|
||||||
getFiles(name, files)
|
getFiles(name, files);
|
||||||
} else {
|
} else {
|
||||||
// If it is a file, push the full path to the files array
|
// If it is a file, push the full path to the files array
|
||||||
files.push(name)
|
files.push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ function registerEndpoints(app, jsonParser) {
|
||||||
if (folder == "live2d") {
|
if (folder == "live2d") {
|
||||||
output[folder] = [];
|
output[folder] = [];
|
||||||
const live2d_folder = path.normalize(path.join(folderPath, folder));
|
const live2d_folder = path.normalize(path.join(folderPath, folder));
|
||||||
const files = getFiles(live2d_folder)
|
const files = getFiles(live2d_folder);
|
||||||
//console.debug("FILE FOUND:",files)
|
//console.debug("FILE FOUND:",files)
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
file = path.normalize(file.replace('public' + path.sep, ''));
|
file = path.normalize(file.replace('public' + path.sep, ''));
|
||||||
|
|
Loading…
Reference in New Issue