Skip to content

Commit

Permalink
feat: add ability to pass in files to check and apply
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Feb 7, 2019
1 parent 00d5bc7 commit 2e7fcdd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/cmds/js_cmds/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { stage_files, staged_files } = require('../../git.js')

const configure = require('../../config.js')

exports.command = 'apply'
exports.command = 'apply [files..]'

exports.describe = 'Apply JS format.'

Expand All @@ -26,12 +26,14 @@ exports.builder = {
}

exports.handler = argv => {
const { all, stage } = argv
const { all, stage, files } = argv
const root_dir = process.cwd()

let codeFiles
if (all) {
codeFiles = collectFiles(root_dir).filter(whitelisted)
} else if (files) {
codeFiles = files
} else {
codeFiles = staged_files(root_dir).filter(whitelisted)
}
Expand Down
10 changes: 6 additions & 4 deletions src/cmds/js_cmds/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const { collectFiles, whitelisted } = require('../../files.js')
const log = require('@dhis2/cli-helpers-engine').reporter

const { check_fmt } = require('../../prettier.js')
const { staged } = require('../../git.js')
const { staged_files } = require('../../git.js')

const configure = require('../../config.js')

exports.command = 'check'
exports.command = 'check [files..]'

exports.describe = 'Check JS format.'

Expand All @@ -20,14 +20,16 @@ exports.builder = {
}

exports.handler = argv => {
const { all } = argv
const { all, files } = argv
const root_dir = process.cwd()

let codeFiles
if (all) {
codeFiles = collectFiles(root_dir).filter(whitelisted)
} else if (files) {
codeFiles = files
} else {
codeFiles = staged(root_dir).filter(whitelisted)
codeFiles = staged_files(root_dir).filter(whitelisted)
}

// debug information about the folders
Expand Down

0 comments on commit 2e7fcdd

Please sign in to comment.