files-compare
Check contents of files or stdin to see if they're all equal.
Last updated a year ago by andersdjohnson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install files-compare 
SYNC missed versions from official npm registry.

files-compare

Check contents of files or stdin to see if they're equal. Includes CLI. Includes asynchronous and synchronous variants.

async

import filesCompare from 'files-compare'

filesCompare([]).then(equal => {
  console.log(equal) // true
})

filesCompare([
  '__fixtures__/one.txt',
  '__fixtures__/two.txt',
  '__fixtures__/three.txt'
]).then(equal => {
  console.log(equal) // true
})

filesCompare([
  '__fixtures__/one.txt',
  '__fixtures__/other.txt',
  '__fixtures__/three.txt'
]).then(equal => {
  console.log(equal) // false
})A

filesCompare([
  '__fixtures__/one.txt',
  '__fixtures__/nonexistent.txt',
  '__fixtures__/three.txt'
]).catch(err => {
  console.error(err)
}

sync

import { sync as filesCompareSync } from 'files-compare'

filesCompareSync([]) // true

filesCompareSync([
  '__fixtures__/one.txt',
  '__fixtures__/two.txt',
  '__fixtures__/three.txt'
]) // true

filesCompareSync([
  '__fixtures__/one.txt',
  '__fixtures__/other.txt',
  '__fixtures__/three.txt'
]) // false

filesCompareSync([
  '__fixtures__/one.txt',
  '__fixtures__/nonexistent.txt',
  '__fixtures__/three.txt'
]) // throws error

CLI

You can execute files-compare from the command line, passing it a space-separated list of files as arguments. To compare with stdin, you can use - in place of one of the file names.

Suppose we have files one.txt, two.txt, and three.txt with identical contents of:

this is same

and also a file other.txt with different contents of:

some other
files-compare ./one.txt ./two.txt ./three.txt
# exit 0

files-compare ./one.txt ./other.txt ./three.txt
# exit 1

echo "this is same" | files-compare - ./one.txt
# exit 0

echo "this is not same" | files-compare - ./one.txt
# exit 1

Current Tags

  • 1.0.2                                ...           latest (a year ago)

3 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |