Updated validator - linter fixes
This commit is contained in:
parent
54468bde29
commit
b67f5f8aa1
|
|
@ -1,15 +1,15 @@
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
const PUBLIC = `public`
|
const PUBLIC = `public`;
|
||||||
const pathOfPublic = path.join(__dirname, '..', PUBLIC);
|
const pathOfPublic = path.join(__dirname, '..', PUBLIC);
|
||||||
|
|
||||||
|
|
||||||
// validating version 2
|
// validating version 2
|
||||||
function validate() {
|
function validate() {
|
||||||
|
|
||||||
const version = '2'
|
const version = '2';
|
||||||
const pathOfVersion = path.join(pathOfPublic, 'v' + version);
|
const pathOfVersion = path.join(pathOfPublic, 'v' + version);
|
||||||
const pathOfApps = path.join(pathOfVersion, 'apps');
|
const pathOfApps = path.join(pathOfVersion, 'apps');
|
||||||
|
|
||||||
|
|
@ -17,15 +17,14 @@
|
||||||
.then(function (items) {
|
.then(function (items) {
|
||||||
|
|
||||||
const apps = items.filter(v => v.includes('.json'));
|
const apps = items.filter(v => v.includes('.json'));
|
||||||
const appDetails = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < apps.length; i++) {
|
for (var i = 0; i < apps.length; i++) {
|
||||||
const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
|
const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
|
||||||
const content = JSON.parse(contentString)
|
const content = JSON.parse(contentString);
|
||||||
const captainVersion = (content.captainVersion + '');
|
const captainVersion = (content.captainVersion + '');
|
||||||
const versionString = (version + '');
|
const versionString = (version + '');
|
||||||
if (versionString !== captainVersion)
|
if (versionString !== captainVersion)
|
||||||
throw new Error(`unmatched versions ${versionString} ${captainVersion} for ${apps[i]}`)
|
throw new Error(`unmatched versions ${versionString} ${captainVersion} for ${apps[i]}`);
|
||||||
|
|
||||||
apps[i] = apps[i].replace('.json', '');
|
apps[i] = apps[i].replace('.json', '');
|
||||||
|
|
||||||
|
|
@ -37,35 +36,28 @@
|
||||||
|
|
||||||
const logoFileName = apps[i] + '.png';
|
const logoFileName = apps[i] + '.png';
|
||||||
|
|
||||||
appDetails[i] = {
|
|
||||||
name: apps[i],
|
|
||||||
displayName: content.displayName,
|
|
||||||
description: content.description,
|
|
||||||
logoUrl: logoFileName
|
|
||||||
}
|
|
||||||
|
|
||||||
const logoFullPath = path.join(pathOfVersion, 'logos', logoFileName);
|
const logoFullPath = path.join(pathOfVersion, 'logos', logoFileName);
|
||||||
|
|
||||||
if (!fs.existsSync(logoFullPath) ||
|
if (!fs.existsSync(logoFullPath) ||
|
||||||
!fs.statSync(logoFullPath).isFile()) {
|
!fs.statSync(logoFullPath).isFile()) {
|
||||||
let printablePath = logoFullPath;
|
let printablePath = logoFullPath;
|
||||||
printablePath = printablePath.substr(printablePath.indexOf(`/${PUBLIC}`))
|
printablePath = printablePath.substr(printablePath.indexOf(`/${PUBLIC}`));
|
||||||
throw new Error(`Cannot find logo for ${apps[i]} ${printablePath}`);
|
throw new Error(`Cannot find logo for ${apps[i]} ${printablePath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Validated ${apps[i]}`)
|
console.log(`Validated ${apps[i]}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return validate()
|
return validate();
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
console.error(err)
|
console.error(err);
|
||||||
process.exit(127)
|
process.exit(127);
|
||||||
})
|
});
|
||||||
Loading…
Reference in New Issue