Modifications du module wpp_checker

This commit is contained in:
Simon Pistache 2023-05-10 08:26:31 +02:00
parent 67f2a9f474
commit b349fe729a
2 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
"scripts": {
"test": "mocha wppChecker.js --require mocha-step --colors"
},
"author": "PtiSimon",
"author": "Simon",
"license": "ISC",
"dependencies": {
"ajv": "^8.5.0",
@ -15,4 +15,4 @@
"mocha": "^8.4.0",
"mocha-steps": "^1.3.0"
}
}
}

View File

@ -37,14 +37,14 @@ function flatReferences(wppManifest) {
describe('Mandatory Checks', function () {
before(function () {
slug = env.PACKAGE_NAME;
const slug = env.PACKAGE_NAME;
expect(slug).to.be.a("string").that.is.not.empty;
root = env.ENTRY_FOLDER;
const root = env.ENTRY_FOLDER;
expect(root).to.be.a("string").that.is.not.empty;
workingDirectory = path.join(root, slug);
files = fs.readdirSync(workingDirectory);
const workingDirectory = path.join(root, slug);
const files = fs.readdirSync(workingDirectory);
expect(files).to.be.an('array').that.is.not.empty;
validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
let validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
});
step('Manifest is an existing json file', function () {
@ -59,7 +59,7 @@ describe('Mandatory Checks', function () {
step('There are no missing files', function () {
let references = flatReferences(wppManifest);
references.push("theme.json");
missings = leftOuterJoin(references, files);
let missings = leftOuterJoin(references, files);
expect(missings,
`The following reference${(missings.length > 1) ? "s" : ""} from theme.json ${(missings.length > 1) ? "are" : "is"} missing in the pack. Consider adding ${(missings.length > 1) ? "them" : " it"} to the pack or removing the reference${(missings.length > 1) ? "s" : ""} from the theme.json:\n\t${missings.join('\n\t• ')}\n`
).to.be.lengthOf(0,);
@ -67,7 +67,7 @@ describe('Mandatory Checks', function () {
step('There are no orphan files', function () {
let references = flatReferences(wppManifest);
orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
let orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
expect(orphans,
`The following orphan file${(orphans.length > 1) ? "s are" : " is"} not referenced in this theme.json. Consider removing the file${(orphans.length > 1) ? "s" : ""} or referencing ${(orphans.length > 1) ? "them" : "it"} in the theme.json:\n\t${orphans.join('\n\t• ')}\n`
).to.be.lengthOf(0);