This action helps you to validate XML syntax in a specified directory. And write back with formatted content. read file recursively with specified file extensions.
If you like my module, please buy me a coffee.
More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me: zhang_nan_163@163.com
Required the path that you assign to read.
the files you want to ignore. split with a comma.
the directories you want to ignore. split with a comma.
file extension that you want to read. such as "config" or "xml". split with comma.
the output of execution.
- create a 'demo' folder
- npm init to create your nodejs package
- copy 'sample_folder' to demo
- npm install anyone-validate-xml to install module
- create 'index.js' and copy code below:
import avx from '@anyone-developer/anyone-validate-xml';
avx(['.config', 'xml'], ['README.md'], ['c'], 'sample_folder').then(result => {
const succeed = result.filter(i => i?.formatted);
const failed = result.filter(i => i?.err);
if (succeed?.length > 0) {
console.info(`[${chalk.greenBright.bgYellowBright.bold('Succeed')}]`);
succeed.forEach(v => {
console.info(chalk.greenBright(`path: ${v.path}`));
});
}
if (succeed?.length > 0 && failed?.length > 0) {
console.log(`---------π${chalk.gray.bold('Happy Delimiter')}π---------`);
}
if (failed?.length > 0) {
console.error(`[${chalk.redBright.bgRedBright.bold('Failed')}]`);
failed.forEach(v => {
console.error(chalk.greenBright(`path: ${v.path} msg: ${v.err?.message}`));
});
}
}).catch(error => console.error(error));
- node index.js to run it
- npm install -g anyone-validate-xml to install gobally
- anyone-validate-xml -r 'sample_folder' -f '.config,.xml' -I ".git" -i "README.md" to use your bash to execute it.
uses: anyone-developer/anyone-validate-xml@main
with:
file-extension: '.config,.xml'
ignore-files: 'README.md'
ignore-directories: '.git'
read-path: 'sample_folder'
PalPal: https://paypal.me/nzhang4