0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Refactored the gscan version check to use single variable

no issue

- Just a small refactor as it was becoming painful to change the version in three places while experimenting with gscan
- Also follows the "rule of 3"
This commit is contained in:
Naz 2022-03-22 09:53:15 +08:00
parent 955f1e8a2e
commit fd14b7eaf6

View file

@ -22,26 +22,27 @@ const check = async function check(theme, isZip) {
debug('Begin: Check');
// gscan can slow down boot time if we require on boot, for now nest the require.
const gscan = require('gscan');
const checkedVersion = 'v4';
let checkedTheme;
if (isZip) {
debug('zip mode');
checkedTheme = await gscan.checkZip(theme, {
keepExtractedDir: true,
checkVersion: 'v4',
checkVersion: checkedVersion,
labs: labs.getAll()
});
} else {
debug('non-zip mode');
checkedTheme = await gscan.check(theme.path, {
checkVersion: 'v4',
checkVersion: checkedVersion,
labs: labs.getAll()
});
}
checkedTheme = gscan.format(checkedTheme, {
onlyFatalErrors: config.get('env') === 'production',
checkVersion: 'v4'
checkVersion: checkedVersion
});
debug('End: Check');