Skip to content

Commit

Permalink
feat: list mode, fix version option
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jun 25, 2019
1 parent 79c7e71 commit 8efbd99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/rollup.js
Expand Up @@ -23,6 +23,7 @@ export default {
delimiters: ['{{ ', ' }}'],
values: {
APP_NAME: metadata.name,
APP_VERSION: metadata.version,
BUILD_JOB: process.env['CI_JOB_ID'],
BUILD_RUNNER: process.env['CI_ENVIRONMENT_SLUG'],
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],
Expand Down
12 changes: 9 additions & 3 deletions src/index.ts
Expand Up @@ -13,7 +13,7 @@ import { VisitorContext } from 'src/visitor/context';
const CONFIG_ARGS_NAME = 'config-name';
const CONFIG_ARGS_PATH = 'config-path';

const MODES = ['check', 'fix'];
const MODES = ['check', 'fix', 'list'];

const RULE_OPTION: Options = {
default: [],
Expand Down Expand Up @@ -54,7 +54,7 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
})
.option('mode', {
alias: ['m'],
choices: ['check', 'fix'],
choices: MODES,
default: 'check',
type: 'string',
})
Expand All @@ -78,7 +78,8 @@ const MAIN_ARGS = usage(`Usage: salty-dog <mode> [options]`)
...RULE_OPTION,
alias: ['t', 'tag'],
})
.help();
.help()
.version(VERSION_INFO.app.version);

const STATUS_SUCCESS = 0;
const STATUS_ERROR = 1;
Expand Down Expand Up @@ -116,6 +117,11 @@ export async function main(argv: Array<string>): Promise<number> {
const rules = await loadRules(args.rules, ctx.ajv);
const activeRules = await resolveRules(rules, args as any);

if (args.mode === 'list') {
logger.info({rules: activeRules}, 'listing active rules');
return STATUS_SUCCESS;
}

for (const data of docs) {
for (const rule of activeRules) {
const items = await rule.pick(ctx, data);
Expand Down
1 change: 1 addition & 0 deletions src/version.ts
@@ -1,6 +1,7 @@
export const VERSION_INFO = {
app: {
name: '{{ APP_NAME }}',
version: '{{ APP_VERSION }}',
},
build: {
job: '{{ BUILD_JOB }}',
Expand Down

0 comments on commit 8efbd99

Please sign in to comment.