Skip to content

Commit

Permalink
Allow version option in cli
Browse files Browse the repository at this point in the history
refs #116

- Added `-v1, --check-version-1` option to allow cli usage of GScan to check for 1.0 theme compatibility
- Pass `options` that includes a `checkVersion` property, which is set to `1.0` when cli called with `-v1`, or `2.0` by default.
  • Loading branch information
aileen committed Jul 25, 2018
1 parent 2c37485 commit 14d4c3b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var pkgJson = require('../package.json'),
chalk = require('chalk'),
gscan = require('../lib'),

options = {},
themePath = '',
levels;

Expand All @@ -15,6 +16,7 @@ program
.arguments('cmd <themePath>')
.option('-p, --pre', 'Run a pre-check only')
.option('-z, --zip', 'Theme path points to a zip file')
.option('-v1, --check-version-1', 'Check theme for Ghost 1.0 compatibility, instead of 2.0')
.action(function (theme) {
themePath = theme;
})
Expand Down Expand Up @@ -62,21 +64,30 @@ function outputResults(theme) {
if (!program.args.length) {
program.help();
} else {
if (program.checkVersion1) {
options.checkVersion = '1.0';
} else {
// CASE: set default value
options.checkVersion = '2.0';
}

if (program.zip) {
console.log('Checking zip file...');
gscan.checkZip(themePath)
gscan.checkZip(themePath, options)
.then(outputResults)
.catch(function (error) {
console.error(error);
});
} else {
console.log('Checking directory...');
gscan.check(themePath).then(outputResults).catch(function ENOTDIRPredicate(err) {
return err.code === 'ENOTDIR';
}, function (err) {
console.error(err.message);
console.error('Did you mean to add the -z flag to read a zip file?');
gscan.check(themePath, options)
.then(outputResults)
.catch(function ENOTDIRPredicate(err) {
return err.code === 'ENOTDIR';
}, function (err) {
console.error(err.message);
console.error('Did you mean to add the -z flag to read a zip file?');
/* eslint-enable no-console */
});
});
}
}

0 comments on commit 14d4c3b

Please sign in to comment.