@anyone-developer/anyone-validate-json
TypeScript icon, indicating that this package has built-in type declarations

0.9.6 • Public • Published

anyone-validate-json

nightly-build release-build release-test FOSSA Status DependaBot version license Build Status XO code style Total alerts Language grade: JavaScript DeepScan grade Gitpod Ready-to-Code

This action helps you to validate JSON 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

Inputs

read-path

Required the path that you assign to read.

ignore-files

the files you want to ignore. split with a comma.

ignore-directories

the directories you want to ignore. split with a comma.

file-extension

file extension that you want to read. such as "config" or "xml". split with comma.

Outputs

output

the output of execution.

Other way usages

From NPM for programmatic use

  • create a 'demo' folder
  • npm init to create your nodejs package
  • copy 'sample_folder' to demo
  • npm install anyone-validate-json to install module
  • create 'index.js' and copy code below:
import avj from '@anyone-developer/anyone-validate-json';

avj(['.config', 'json'], ['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

From NPM for using as a command-line app

  • npm install -g anyone-validate-json to install gobally
  • anyone-validate-json -r 'sample_folder' -f '.config,.json' -I ".git" -i "README.md" to use your bash to execute it.

Example usage

uses: anyone-developer/anyone-validate-json@main
with:
  file-extension: '.config,.json'
  ignore-files: 'README.md'
  ignore-directories: '.git'
  read-path: 'sample_folder'

Fossa Report

FOSSA Status

Donation

PalPal: https://paypal.me/nzhang4

Package Sidebar

Install

npm i @anyone-developer/anyone-validate-json

Weekly Downloads

3

Version

0.9.6

License

GPL-3.0-or-later

Unpacked Size

46.5 kB

Total Files

11

Last publish

Collaborators

  • edward.zhang