Exemple #1
0
 return findUp(GIT).then(gitDirectory => {
   if (gitDirectory) {
     if (R.endsWith(GIT, gitDirectory)) {
       gitDirectory = gitDirectory.replace(GIT, '')
     }
     debug('found %s', gitDirectory)
     return gitDirectory
   }
   throw new Error(`Could not find ${GIT} folder up from ${process.cwd()}`)
 })
Exemple #2
0
function stripSeparator (folder) {
  if (R.endsWith(path.sep, folder)) {
    return folder.substr(0, folder.length - path.sep.length)
  }
  return folder
}
 it('checks to see if one string is inside of another', () => {
   const result: boolean = _.endsWith("a")("abc");
 })
 it('checks to see if one element of an array is ending in another array', () => {
   const result: boolean = _.endsWith(["a"], ["a", "b", "c"]);
 })
 it('catches mismatches between the inner array elements', () => {
   // It is not understood why this isn't flagged as an error.
   // $ShouldExpectErrorButInsteadWorksPleaseFix
   _.endsWith(["1"], [1, 2, 3])
 })
 it('catches mismatches between the first set and the second', () => {
   // $ExpectError
   _.endsWith("1", [1, 2, 3])
 })
 it('allows any number of elements to be used as the comparator', () => {
   const result: boolean = _.endsWith([1, 2, 3], [1, 2, 3]);
 })
 it('can check any type (not just strings) for the ending of an array', () => {
   const result: boolean = _.endsWith([1], [1, 2, 3]);
 })
Exemple #9
0
  prop,
  propEq,
  split,
  sum,
  tap,
} from 'ramda'
import { getChangedLinesFromDiff } from './lib/git'

const linter = new CLIEngine()
const formatter = linter.getFormatter()

const getChangedFiles = pipeP(
  commitRange => exec('git', ['diff', commitRange, '--name-only', '--diff-filter=ACM']),
  prop('stdout'),
  split('\n'),
  filter(endsWith('.js')),
  map(path.resolve)
)

const getDiff = curry((commitRange, filename) =>
  exec('git', ['diff', commitRange, filename])
    .then(prop('stdout')))

const getChangedFileLineMap = curry((commitRange, filePath) => pipeP(
  getDiff(commitRange),
  getChangedLinesFromDiff,
  objOf('changedLines'),
  assoc('filePath', filePath)
)(filePath))

const lintChangedLines = pipe(