Skip to content

Commit

Permalink
feat(multiple): handle multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 16, 2017
1 parent 8dd4acd commit 1e31f57
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ script:
- DEBUG=ok-file node bin/ok-file.js package.json .travis.yml
- DEBUG=ok-file node bin/ok-file.js src/*.js
- DEBUG=ok-file node bin/ok-file.js does/not/exist || true
- DEBUG=ok-file node bin/ok-file.js package.json 'src/*.js'
after_success:
- npm run semantic-release
branches:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ You can even pass a wild card string to find files
$(npm bin)/ok-file 'videso/*.mp4'
```

You can combine filenames with wild cards

```
$(npm bin)/ok-file package.json 'src/*.js'
```

## Debugging

Run program with `DEBUG=ok-file ...` environment variable
Expand Down
11 changes: 6 additions & 5 deletions bin/ok-file.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env node

const okFile = require('..')
const filename = process.argv[2]
const filenames = process.argv.slice(2)

if (!filename) {
console.error('usage: ok-file <filename>')
console.error('checks if file exists and is not empty')
if (!filenames.length) {
console.error('usage: ok-file <filename1> <filename2>')
console.error("or: ok-file '<wild card>'")
console.error('checks if each file exists and is not empty')
process.exit(1)
}

if (!okFile(filename)) {
if (!filenames.every(okFile)) {
process.exit(1)
}

0 comments on commit 1e31f57

Please sign in to comment.