Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature ignorefile #94

Merged
merged 21 commits into from
Sep 10, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change the name function for clarity and change 'var' to 'const/let' …
…syntax
  • Loading branch information
Vinícius Carvalho committed Sep 8, 2019
commit c6fcee73fecdbbc6a700dee2858d371cc4f59d47
23 changes: 11 additions & 12 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node

var onchange = require('./')
var arrify = require('arrify')
var { readFileSync, lstatSync, existsSync } = require('fs')
const onchange = require('./')
const arrify = require('arrify')
const { readFileSync, lstatSync, existsSync } = require('fs')

// Parse argv with minimist...it's easier this way.
var argv = require('minimist')(process.argv.slice(2), {
const argv = require('minimist')(process.argv.slice(2), {
'--': true,
boolean: ['v', 'i', 'k', 'a'],
string: ['e', 'c', 'killSignal'],
Expand Down Expand Up @@ -34,20 +34,19 @@ if (!argv._.length || argv.help) {
}

// Setup some storage variables
var matches = argv._.slice()
var args = argv['--'].slice()
var command = args.shift()
const matches = argv._.slice()
const args = argv['--'].slice()
const command = args.shift()

// Init config ignored files
const ignorePathDefault = './.onchangeignore'

const ignorePath = typeof argv['ignore-path'] === 'string'
? argv['ignore-path']
: ignorePathDefault

const exclude = typeof argv.exclude === 'boolean' ? [] : arrify(argv.exclude)

var options = {
exclude: getIgnoreMergedFromIgnoreFile(exclude, ignorePath),
const options = {
exclude: getExcludeMergedWithIgnoreFile(exclude, ignorePath),
verbose: argv.verbose,
add: argv.add,
initial: argv.initial,
Expand All @@ -63,7 +62,7 @@ var options = {
ignorePath
}

function getIgnoreMergedFromIgnoreFile(exclude = [], ignorePath = ignorePathDefault) {
function getExcludeMergedWithIgnoreFile(exclude = [], ignorePath = ignorePathDefault) {
if(existsSync(ignorePath)) {

if (!lstatSync(ignorePath).isFile()) {
Expand Down