diff -Nru node-findup-sync-0.1.3/debian/changelog node-findup-sync-0.4.3/debian/changelog --- node-findup-sync-0.1.3/debian/changelog 2016-11-01 12:49:51.000000000 +0000 +++ node-findup-sync-0.4.3/debian/changelog 2016-11-09 10:21:02.000000000 +0000 @@ -1,3 +1,10 @@ +node-findup-sync (0.4.3-1) unstable; urgency=medium + + * Team upload + * New upstream release + + -- Sruthi Chandran Wed, 09 Nov 2016 14:47:38 +0530 + node-findup-sync (0.1.3-2) unstable; urgency=low * Team upload. diff -Nru node-findup-sync-0.1.3/debian/control node-findup-sync-0.4.3/debian/control --- node-findup-sync-0.1.3/debian/control 2016-11-01 12:49:51.000000000 +0000 +++ node-findup-sync-0.4.3/debian/control 2016-11-09 10:21:02.000000000 +0000 @@ -3,15 +3,24 @@ Priority: optional Maintainer: Debian Javascript Maintainers Uploaders: Matthew Pideil -Build-Depends: debhelper (>= 9.0.0) +Build-Depends: + debhelper (>= 9) + , dh-buildinfo + , nodejs Standards-Version: 3.9.8 Homepage: https://github.com/cowboy/node-findup-sync Vcs-Git: https://anonscm.debian.org/git/pkg-javascript/node-findup-sync.git -Vcs-Browser: https://anonscm.debian.org/git/pkg-javascript/node-findup-sync.git +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-javascript/node-findup-sync.git Package: node-findup-sync Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, nodejs, node-glob, node-lodash +Depends: + ${misc:Depends} + , nodejs + , node-detect-file (>= 0.1.0) + , node-is-glob (>= 2.0.1) + , node-micromatch (>= 2.3.7) + , node-resolve-dir (>= 0.1.0) Recommends: javascript-common Description: filename searcher function - Node.js module Find the first file matching a given pattern in the current directory or the diff -Nru node-findup-sync-0.1.3/debian/install node-findup-sync-0.4.3/debian/install --- node-findup-sync-0.1.3/debian/install 2016-10-30 10:33:00.000000000 +0000 +++ node-findup-sync-0.4.3/debian/install 2016-11-09 10:21:02.000000000 +0000 @@ -1 +1 @@ -lib/* /usr/lib/nodejs/ +index.js usr/lib/nodejs/findup-sync/ diff -Nru node-findup-sync-0.1.3/debian/tests/control node-findup-sync-0.4.3/debian/tests/control --- node-findup-sync-0.1.3/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/debian/tests/control 2016-11-09 10:21:02.000000000 +0000 @@ -0,0 +1,2 @@ +Tests: require +Depends: node-findup-sync diff -Nru node-findup-sync-0.1.3/debian/tests/require node-findup-sync-0.4.3/debian/tests/require --- node-findup-sync-0.1.3/debian/tests/require 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/debian/tests/require 2016-11-09 10:21:02.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +nodejs -e "require('findup-sync');" diff -Nru node-findup-sync-0.1.3/.gitattributes node-findup-sync-0.4.3/.gitattributes --- node-findup-sync-0.1.3/.gitattributes 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/.gitattributes 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,7 @@ +# Enforce Unix newlines +*.* text eol=lf + +*.jpg binary +*.gif binary +*.png binary +*.jpeg binary \ No newline at end of file diff -Nru node-findup-sync-0.1.3/.gitignore node-findup-sync-0.4.3/.gitignore --- node-findup-sync-0.1.3/.gitignore 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/.gitignore 2016-10-12 21:43:14.000000000 +0000 @@ -1 +1,5 @@ -/node_modules/ +*.DS_Store +*.sublime-* +node_modules +npm-debug.log +test/actual diff -Nru node-findup-sync-0.1.3/Gruntfile.js node-findup-sync-0.4.3/Gruntfile.js --- node-findup-sync-0.1.3/Gruntfile.js 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/Gruntfile.js 2016-10-12 21:43:14.000000000 +0000 @@ -4,22 +4,17 @@ // Project configuration. grunt.initConfig({ - nodeunit: { - files: ['test/**/*_test.js'], - }, jshint: { options: { jshintrc: '.jshintrc' }, - all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'] + all: ['*.js', 'test/{,support/}*.js'] } }); // Load plugins. grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); // Default task. - grunt.registerTask('default', ['jshint', 'nodeunit']); - + grunt.registerTask('default', ['jshint']); }; diff -Nru node-findup-sync-0.1.3/index.js node-findup-sync-0.4.3/index.js --- node-findup-sync-0.1.3/index.js 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/index.js 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,85 @@ +'use strict'; + +/** + * Module dependencies + */ + +var fs = require('fs'); +var path = require('path'); +var isGlob = require('is-glob'); +var resolveDir = require('resolve-dir'); +var detect = require('detect-file'); +var mm = require('micromatch'); + +/** + * @param {String|Array} `pattern` Glob pattern or file path(s) to match against. + * @param {Object} `options` Options to pass to [micromatch]. Note that if you want to start in a different directory than the current working directory, specify the `options.cwd` property here. + * @return {String} Returns the first matching file. + * @api public + */ + +module.exports = function(patterns, options) { + options = options || {}; + var cwd = path.resolve(resolveDir(options.cwd || '')); + + if (typeof patterns === 'string') { + return lookup(cwd, [patterns], options); + } + + if (!Array.isArray(patterns)) { + throw new TypeError('findup-sync expects a string or array as the first argument.'); + } + + return lookup(cwd, patterns, options); +}; + +function lookup(cwd, patterns, options) { + var len = patterns.length; + var idx = -1; + var res; + + while (++idx < len) { + if (isGlob(patterns[idx])) { + res = matchFile(cwd, patterns[idx], options); + } else { + res = findFile(cwd, patterns[idx], options); + } + if (res) { + return res; + } + } + + var dir = path.dirname(cwd); + if (dir === cwd) { + return null; + } + return lookup(dir, patterns, options); +} + +function matchFile(cwd, pattern, opts) { + var isMatch = mm.matcher(pattern, opts); + var files = tryReaddirSync(cwd); + var len = files.length; + var idx = -1; + + while (++idx < len) { + var name = files[idx]; + var fp = path.join(cwd, name); + if (isMatch(name) || isMatch(fp)) { + return fp; + } + } + return null; +} + +function findFile(cwd, filename, options) { + var fp = cwd ? path.resolve(cwd, filename) : filename; + return detect(fp, options); +} + +function tryReaddirSync(fp) { + try { + return fs.readdirSync(fp); + } catch(err) {} + return []; +} diff -Nru node-findup-sync-0.1.3/.jshintrc node-findup-sync-0.4.3/.jshintrc --- node-findup-sync-0.1.3/.jshintrc 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/.jshintrc 2016-10-12 21:43:14.000000000 +0000 @@ -1,15 +1,19 @@ { - "loopfunc": true, + "asi": false, + "boss": true, "curly": true, "eqeqeq": true, + "eqnull": true, + "esnext": true, "immed": true, - "latedef": true, + "latedef": false, + "laxbreak": true, + "laxcomma": false, "newcap": true, "noarg": true, + "node": true, "sub": true, "undef": true, "unused": true, - "boss": true, - "eqnull": true, - "node": true -} + "mocha": true +} \ No newline at end of file diff -Nru node-findup-sync-0.1.3/lib/findup-sync.js node-findup-sync-0.4.3/lib/findup-sync.js --- node-findup-sync-0.1.3/lib/findup-sync.js 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/lib/findup-sync.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* - * findup-sync - * https://github.com/cowboy/node-findup-sync - * - * Copyright (c) 2013 "Cowboy" Ben Alman - * Licensed under the MIT license. - */ - -'use strict'; - -// Nodejs libs. -var path = require('path'); - -// External libs. -var glob = require('glob'); -var _ = require('lodash'); - -// Search for a filename in the given directory or all parent directories. -module.exports = function(patterns, options) { - // Normalize patterns to an array. - if (!Array.isArray(patterns)) { patterns = [patterns]; } - // Create globOptions so that it can be modified without mutating the - // original object. - var globOptions = Object.create(options || {}); - globOptions.maxDepth = 1; - globOptions.cwd = path.resolve(globOptions.cwd || '.'); - - var files, lastpath; - do { - // Search for files matching patterns. - files = _(patterns).map(function(pattern) { - return glob.sync(pattern, globOptions); - }).flatten().uniq().value(); - // Return file if found. - if (files.length > 0) { - return path.resolve(path.join(globOptions.cwd, files[0])); - } - // Go up a directory. - lastpath = globOptions.cwd; - globOptions.cwd = path.resolve(globOptions.cwd, '..'); - // If parentpath is the same as basedir, we can't go any higher. - } while (globOptions.cwd !== lastpath); - - // No files were found! - return null; -}; diff -Nru node-findup-sync-0.1.3/LICENSE-MIT node-findup-sync-0.4.3/LICENSE-MIT --- node-findup-sync-0.1.3/LICENSE-MIT 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/LICENSE-MIT 2016-10-12 21:43:14.000000000 +0000 @@ -1,4 +1,6 @@ -Copyright (c) 2013 "Cowboy" Ben Alman +The MIT License (MIT) + +Copyright (c) 2013-2016, "Cowboy" Ben Alman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff -Nru node-findup-sync-0.1.3/package.json node-findup-sync-0.4.3/package.json --- node-findup-sync-0.1.3/package.json 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -1,44 +1,50 @@ { "name": "findup-sync", "description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.", - "version": "0.1.3", + "version": "0.4.3", "homepage": "https://github.com/cowboy/node-findup-sync", - "author": { - "name": "\"Cowboy\" Ben Alman", - "url": "http://benalman.com/" - }, - "repository": { - "type": "git", - "url": "git://github.com/cowboy/node-findup-sync.git" - }, + "author": "\"Cowboy\" Ben Alman (http://benalman.com)", + "repository": "cowboy/node-findup-sync", "bugs": { "url": "https://github.com/cowboy/node-findup-sync/issues" }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/cowboy/node-findup-sync/blob/master/LICENSE-MIT" - } + "license": "MIT", + "files": [ + "index.js" ], - "main": "lib/findup-sync", + "main": "index.js", "engines": { - "node": ">= 0.6.0" + "node": ">= 0.8.0" }, "scripts": { - "test": "grunt nodeunit" + "test": "grunt && mocha" }, "dependencies": { - "glob": "~3.2.9", - "lodash": "~2.4.1" + "detect-file": "^0.1.0", + "is-glob": "^2.0.1", + "micromatch": "^2.3.7", + "resolve-dir": "^0.1.0" }, "devDependencies": { - "grunt": "~0.4.4", - "grunt-contrib-jshint": "~0.9.2", - "grunt-contrib-nodeunit": "~0.3.3" + "fs-exists-sync": "^0.1.0", + "grunt": "^1.0.1", + "grunt-contrib-jshint": "^0.12.0", + "is-absolute": "^0.2.3", + "minimist": "^1.2.0", + "mocha": "^2.4.5", + "normalize-path": "^2.0.1", + "os-homedir": "^1.0.1", + "resolve": "^1.1.7" }, "keywords": [ + "file", "find", + "find-up", + "findup", "glob", - "file" + "match", + "pattern", + "resolve", + "search" ] } diff -Nru node-findup-sync-0.1.3/README.md node-findup-sync-0.4.3/README.md --- node-findup-sync-0.1.3/README.md 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/README.md 2016-10-12 21:43:14.000000000 +0000 @@ -1,12 +1,20 @@ -# findup-sync [![Build Status](https://secure.travis-ci.org/cowboy/node-findup-sync.png?branch=master)](http://travis-ci.org/cowboy/node-findup-sync) +# findup-sync [![Build Status](https://travis-ci.org/js-cli/node-findup-sync.svg)](https://travis-ci.org/js-cli/node-findup-sync) [![NPM version](https://badge.fury.io/js/findup-sync.svg)](http://badge.fury.io/js/findup-sync) -Find the first file matching a given pattern in the current directory or the nearest ancestor directory. +> Find the first file matching a given pattern in the current directory or the nearest ancestor directory. -## Getting Started -Install the module with: `npm install findup-sync` +Matching is done with [micromatch][], please report any matching related issues on that repository. + +## Install with [npm](npmjs.org) + +```bash +npm i findup-sync --save +``` + +## Usage ```js var findup = require('findup-sync'); +findup(patternOrPatterns [, micromatchOptions]); // Start looking in the CWD. var filepath1 = findup('{a,b}*.txt'); @@ -15,31 +23,45 @@ var filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true}); ``` -## Usage - -```js -findup(patternOrPatterns [, minimatchOptions]) -``` +* `patterns` **{String|Array}**: Glob pattern(s) or file path(s) to match against. +* `options` **{Object}**: Options to pass to [micromatch]. Note that if you want to start in a different directory than the current working directory, specify a `cwd` property here. +* `returns` **{String}**: Returns the first matching file. -### patternOrPatterns -Type: `String` or `Array` -Default: none +## Running tests -One or more wildcard glob patterns. Or just filenames. +Install dev dependencies: -### minimatchOptions -Type: `Object` -Default: `{}` +```bash +npm i -d && npm test +``` -Options to be passed to [minimatch](https://github.com/isaacs/minimatch). +## Contributing -Note that if you want to start in a different directory than the current working directory, specify a `cwd` property here. +In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/) -## Contributing -In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). +For bugs and feature requests, [please create an issue](https://github.com/cowboy/node-findup-sync/issues). ## Release History + +2015-01-30 - v0.4.0 - Refactored, not also uses [micromatch][] instead of minimatch. +2015-09-14 - v0.3.0 - updated glob to ~5.0. +2014-12-17 - v0.2.1 - Updated to glob 4.3. +2014-12-16 - v0.2.0 - Removed lodash, updated to glob 4.x. 2014-03-14 - v0.1.3 - Updated dependencies. 2013-03-08 - v0.1.2 - Updated dependencies. Fixed a Node 0.9.x bug. Updated unit tests to work cross-platform. 2012-11-15 - v0.1.1 - Now works without an options object. -2012-11-01 - v0.1.0 - Initial release. +2012-11-01 - v0.1.0 - Initial release. + +## Authors + +**"Cowboy" Ben Alman** + ++ [github/cowboy](https://github.com/cowboy) ++ [twitter/cowboy](http://twitter.com/cowboy) + +## License + +Copyright (c) 2012-2016 "Cowboy" Ben Alman +Released under the MIT license + +[micromatch]: http://github.com/jonschlinkert/micromatch diff -Nru node-findup-sync-0.1.3/test/findup-sync_test.js node-findup-sync-0.4.3/test/findup-sync_test.js --- node-findup-sync-0.1.3/test/findup-sync_test.js 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/test/findup-sync_test.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -'use strict'; - -// Nodejs lib. -var path = require('path'); - -var findup = require('../lib/findup-sync.js'); - -// Get a relative path. -var rel = function(abspath) { - return typeof abspath === 'string' ? path.relative('.', abspath) : abspath; -}; - -exports['findup'] = { - setUp: function(done) { - this.cwd = process.cwd(); - done(); - }, - tearDown: function(done) { - process.chdir(this.cwd); - done(); - }, - 'simple': function(test) { - test.expect(8); - var opts = {cwd: 'test/fixtures/a/b'}; - test.equal(rel(findup('foo.txt', opts)), path.normalize('test/fixtures/a/foo.txt'), 'should find files'); - test.equal(rel(findup('bar.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find files'); - test.equal(rel(findup('a.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should find files'); - test.equal(rel(findup('?.txt', opts)), path.normalize('test/fixtures/a.txt'), 'should support glob patterns'); - test.equal(rel(findup('*.txt', opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches the glob pattern'); - test.equal(rel(findup(['b*.txt', 'f*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns'); - test.equal(rel(findup(['f*.txt', 'b*.txt'], opts)), path.normalize('test/fixtures/a/b/bar.txt'), 'should find the first thing that matches any of the glob patterns'); - test.equal(findup('not-gonna-exist-i-hope.txt', opts), null, 'should returning null if no files found'); - test.done(); - }, - 'cwd': function(test) { - test.expect(8); - process.chdir('test/fixtures/a/b'); - test.equal(rel(findup('foo.txt')), path.normalize('../foo.txt'), 'should find files'); - test.equal(rel(findup('bar.txt')), 'bar.txt', 'should find files'); - test.equal(rel(findup('a.txt')), path.normalize('../../a.txt'), 'should find files'); - test.equal(rel(findup('?.txt')), path.normalize('../../a.txt'), 'should support glob patterns'); - test.equal(rel(findup('*.txt')), 'bar.txt', 'should find the first thing that matches the glob pattern'); - test.equal(rel(findup(['b*.txt', 'f*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns'); - test.equal(rel(findup(['f*.txt', 'b*.txt'])), 'bar.txt', 'should find the first thing that matches any of the glob patterns'); - test.equal(findup('not-gonna-exist-i-hope.txt'), null, 'should returning null if no files found'); - test.done(); - }, -}; diff -Nru node-findup-sync-0.1.3/test/fixtures/a/a.txt node-findup-sync-0.4.3/test/fixtures/a/a.txt --- node-findup-sync-0.1.3/test/fixtures/a/a.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/a.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +a diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/b.txt node-findup-sync-0.4.3/test/fixtures/a/b/b.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/b.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/b.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +b diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/c.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/c.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/c.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/c.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +c diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/d.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/d.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/d.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/d.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +d diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/e.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/e.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/e.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/e.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +e diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +f diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/f.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/f.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/f.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/f.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +f diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +g diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/g.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/g.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/g.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/g.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +g diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +h diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/h.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/h.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/h.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/h.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +h diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +i diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/i.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/i.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/i.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/i.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +i diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +j diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/j.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/j.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/j.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/j.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +j diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/j/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +j diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/i/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/i/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +i diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +h diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/h/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/h/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "h", + "description": "package.json from h." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +g diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/g/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/g/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "g", + "description": "package.json from g." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +f diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/f/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/f/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "f", + "description": "package.json from f." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +e diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +e diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/e/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/e/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "e", + "description": "package.json from e." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +d diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/d/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +d diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/d/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/d/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/d/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/d/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "d", + "description": "package.json from d." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +c diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/c/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/c/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +c diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/c/package.json node-findup-sync-0.4.3/test/fixtures/a/b/c/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/c/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/c/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "c", + "description": "package.json from c." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/file.txt node-findup-sync-0.4.3/test/fixtures/a/b/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +b diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/b/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/b/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +b diff -Nru node-findup-sync-0.1.3/test/fixtures/a/b/package.json node-findup-sync-0.4.3/test/fixtures/a/b/package.json --- node-findup-sync-0.1.3/test/fixtures/a/b/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/b/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "b", + "description": "package.json from b." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/a/file.txt node-findup-sync-0.4.3/test/fixtures/a/file.txt --- node-findup-sync-0.1.3/test/fixtures/a/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +a diff -Nru node-findup-sync-0.1.3/test/fixtures/a/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/a/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/a/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +a diff -Nru node-findup-sync-0.1.3/test/fixtures/a/package.json node-findup-sync-0.4.3/test/fixtures/a/package.json --- node-findup-sync-0.1.3/test/fixtures/a/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/a/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "a", + "description": "package.json from a." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/file.txt node-findup-sync-0.4.3/test/fixtures/file.txt --- node-findup-sync-0.1.3/test/fixtures/file.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/file.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +root diff -Nru node-findup-sync-0.1.3/test/fixtures/Mochafile.txt node-findup-sync-0.4.3/test/fixtures/Mochafile.txt --- node-findup-sync-0.1.3/test/fixtures/Mochafile.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/Mochafile.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +root diff -Nru node-findup-sync-0.1.3/test/fixtures/package.json node-findup-sync-0.4.3/test/fixtures/package.json --- node-findup-sync-0.1.3/test/fixtures/package.json 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/package.json 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,4 @@ +{ + "name": "fixtures", + "description": "package.json from ./fixtures." +} diff -Nru node-findup-sync-0.1.3/test/fixtures/root.txt node-findup-sync-0.4.3/test/fixtures/root.txt --- node-findup-sync-0.1.3/test/fixtures/root.txt 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/fixtures/root.txt 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1 @@ +root diff -Nru node-findup-sync-0.1.3/test/support/index.js node-findup-sync-0.4.3/test/support/index.js --- node-findup-sync-0.1.3/test/support/index.js 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/support/index.js 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,51 @@ +'use strict'; + +var path = require('path'); +var normalizePath = require('normalize-path'); +var isAbsolute = require('is-absolute'); +var resolve = require('resolve'); + +exports.normalize = function(filepath) { + return filepath ? normalizePath(path.relative('.', filepath)) : null; +}; + +exports.chdir = function(dir) { + // store current cwd + var orig = process.cwd(); + // set cwd to the given `dir` + process.chdir(dir); + return function() { + // restore original `cwd` + process.chdir(orig); + }; +}; + +exports.npm = function npm(name) { + return path.dirname(resolve.sync(name)); +}; + +exports.assert = function(assert) { + assert.isPath = function (filepath) { + assert(filepath); + assert.equal(typeof filepath, 'string'); + }; + + assert.isAbsolute = function (filepath) { + assert(filepath); + assert.equal(typeof filepath, 'string'); + assert(isAbsolute(filepath)); + }; + + assert.basename = function (filepath, basename) { + assert(filepath); + assert.equal(typeof filepath, 'string'); + assert.equal(path.basename(filepath), basename); + }; + + assert.dirname = function (filepath, dirname) { + assert(filepath); + assert.equal(typeof filepath, 'string'); + assert.equal(path.dirname(path.resolve(filepath)), path.resolve(dirname)); + }; +}; + diff -Nru node-findup-sync-0.1.3/test/test.js node-findup-sync-0.4.3/test/test.js --- node-findup-sync-0.1.3/test/test.js 1970-01-01 00:00:00.000000000 +0000 +++ node-findup-sync-0.4.3/test/test.js 2016-10-12 21:43:14.000000000 +0000 @@ -0,0 +1,302 @@ +'use strict'; + +require('mocha'); +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); +var support = require('./support'); +support.assert(assert); +var home = require('os-homedir'); +var exists = require('fs-exists-sync'); +var resolve = require('resolve'); +var findup = require('../'); +var normalize = support.normalize; +var chdir = support.chdir; +var npm = support.npm; +var cwd; +var actual; +var isLinux = process.platform === 'linux'; + + +describe('findup-sync', function () { + before(function () { + fs.writeFileSync(home() + '/_aaa.txt', ''); + fs.writeFileSync(home() + '/_bbb.txt', ''); + }); + after(function () { + fs.unlinkSync(home() + '/_aaa.txt'); + fs.unlinkSync(home() + '/_bbb.txt'); + }); + + it('should throw when the first arg is not a string or array:', function(cb) { + try { + findup(); + cb(new Error('expected an error')); + } catch (err) { + assert.equal(err.message, 'findup-sync expects a string or array as the first argument.'); + cb(); + } + }); + + it('should work when no cwd is given', function () { + var actual = findup('package.json'); + assert(actual); + assert.dirname(actual, path.resolve(__dirname, '..')); + assert.basename(actual, 'package.json'); + assert.equal(normalize(findup('package.json')), 'package.json'); + }); + + it('should find files in a child directory', function () { + var expected = path.resolve(__dirname, 'fixtures/a/b/file.txt'); + var restore = chdir(path.resolve(__dirname, 'fixtures/a/b/c/d/e/f/g/h')); + + var actual = findup('a/b/file.txt'); + assert(actual); + assert(exists(actual)); + assert.equal(actual, expected); + restore(); + }); + + it('should find case sensitive files in a child directory', function () { + var expected = path.resolve(__dirname, 'fixtures/a/b/', (isLinux ? 'Mochafile.txt' : 'mochafile.txt')); + var restore = chdir(path.resolve(__dirname, 'fixtures/a/b/c/d/e/f/g/h')); + + var actual = findup('a/b/mochafile.txt', {nocase: true}); + assert(actual); + assert(exists(actual)); + assert.equal(actual, expected); + restore(); + }); + + it('should find files in a child directory relative to a cwd', function () { + var expectedFile = path.resolve(__dirname, 'fixtures/a/b/file.txt'); + var expectedA = path.resolve(__dirname, 'fixtures/a/a.txt'); + var tempDir = chdir(path.resolve(__dirname, 'fixtures')); + + var actualFile = findup('a/b/file.txt', {cwd: 'a/b/c/d'}); + assert(actualFile); + assert(exists(actualFile)); + assert.equal(actualFile, expectedFile); + + var actualA = findup('a.txt', {cwd: 'a/b/c/d/e/f'}); + assert(actualA); + assert(exists(actualA)); + assert.equal(actualA, expectedA); + tempDir(); + }); + + it('should find case sensitive files in a child directory relative to a cwd', function () { + var expectedFile = path.resolve(__dirname, 'fixtures/a/b', (isLinux ? 'Mochafile.txt' : 'mochafile.txt')); + var expectedA = path.resolve(__dirname, 'fixtures/a/a.txt'); + var tempDir = chdir(path.resolve(__dirname, 'fixtures')); + + var actualFile = findup('a/b/mochafile.txt', {cwd: 'a/b/c/d', nocase: true}); + assert(actualFile); + assert(exists(actualFile)); + assert.equal(actualFile, expectedFile); + + var actualA = findup('a.txt', {cwd: 'a/b/c/d/e/f'}); + assert(actualA); + assert(exists(actualA)); + assert.equal(actualA, expectedA); + tempDir(); + }); + + it('should support normal (non-glob) file paths:', function () { + var normPath = normalize(findup('package.json', {cwd: path.dirname(resolve.sync('normalize-path'))})); + assert.equal(normPath, 'node_modules/normalize-path/package.json'); + + var isGlob = normalize(findup('package.json', {cwd: path.dirname(resolve.sync('is-glob'))})); + assert.equal(isGlob, 'node_modules/is-glob/package.json'); + + cwd = path.dirname(resolve.sync('normalize-path')); + var actual = findup('package.json', {cwd: cwd}); + assert.dirname(actual, cwd); + assert.basename(actual, 'package.json'); + + actual = findup('c/package.json', {cwd: 'test/fixtures/a/b/c/d/e/f/g'}); + assert.basename(actual, 'package.json'); + assert.dirname(actual, 'test/fixtures/a/b/c'); + + cwd = path.dirname(resolve.sync('is-glob')); + actual = findup('package.json', {cwd: cwd}); + assert.dirname(actual, cwd); + assert.basename(actual, 'package.json'); + }); + + it('should support normal (non-glob) case sensitive file paths:', function () { + actual = findup('c/mochafile.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true}); + assert.basename(actual, (isLinux ? 'Mochafile.txt' : 'mochafile.txt')); + assert.dirname(actual, 'test/fixtures/a/b/c'); + }); + + it('should support glob patterns', function() { + assert.equal(normalize(findup('**/c/package.json', {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/package.json'); + assert.equal(normalize(findup('**/one.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/d/one.txt'); + assert.equal(normalize(findup('**/two.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/two.txt'); + + var pkg = normalize(findup('p*.json', {cwd: npm('micromatch')})); + assert.equal(pkg, 'node_modules/micromatch/package.json'); + + var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g'}; + + actual = findup('**/c/package.json', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'package.json'); + + actual = findup('c/package.json', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'package.json'); + + actual = findup('**/ONE.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'ONE.txt'); + + actual = findup('**/two.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'two.txt'); + + cwd = npm('is-glob'); + actual = findup('p*.json', {cwd: cwd}); + assert.dirname(actual, cwd); + assert.basename(actual, 'package.json'); + }); + + it('should support case sensitive glob patterns', function() { + assert.equal(normalize(findup('**/c/mochafile.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true})), 'test/fixtures/a/b/c/Mochafile.txt'); + assert.equal(normalize(findup('**/one.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true})), 'test/fixtures/a/b/c/d/one.txt'); + assert.equal(normalize(findup('**/two.txt', {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true})), 'test/fixtures/a/b/c/two.txt'); + + assert.equal(normalize(findup('mocha*', {cwd: 'test/fixtures/a/b/c', nocase: true})), 'test/fixtures/a/b/c/Mochafile.txt'); + + var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true}; + + actual = findup('**/c/mochafile.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'Mochafile.txt'); + + actual = findup('c/mochafile.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, (isLinux ? 'Mochafile.txt' : 'mochafile.txt')); + + opts.nocase = false; + actual = findup('**/ONE.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'ONE.txt'); + + actual = findup('**/two.txt', opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'two.txt'); + }); + + it('should support arrays of glob patterns', function() { + assert.equal(normalize(findup(['**/c/package.json'], {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/package.json'); + assert.equal(normalize(findup(['**/one.txt'], {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/d/one.txt'); + assert.equal(normalize(findup(['**/two.txt'], {cwd: 'test/fixtures/a/b/c/d/e/f/g'})), 'test/fixtures/a/b/c/two.txt'); + + var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g'}; + + actual = findup(['lslsl', '**/c/package.json'], opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'package.json'); + + actual = findup(['lslsl', 'c/package.json'], opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'package.json'); + + actual = findup(['lslsl', '**/ONE.txt'], opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'ONE.txt'); + + actual = findup(['lslsl', '**/two.txt'], opts); + assert.dirname(actual, 'test/fixtures/a/b/c'); + assert.basename(actual, 'two.txt'); + + actual = findup(['lslsl', '**/blah.txt'], opts); + assert(actual === null); + + cwd = npm('is-glob'); + actual = findup(['lslsl', 'p*.json'], {cwd: cwd}); + assert.dirname(actual, cwd); + assert.basename(actual, 'package.json'); + }); + + it('should support micromatch `matchBase` option:', function() { + var opts = { matchBase: true, cwd: 'test/fixtures/a/b/c/d/e/f/g' }; + assert.equal(normalize(findup('package.json', opts)), 'test/fixtures/a/b/c/d/e/f/g/package.json'); + assert.equal(normalize(findup('one.txt', opts)), 'test/fixtures/a/b/c/d/one.txt'); + assert.equal(normalize(findup('two.txt', opts)), 'test/fixtures/a/b/c/two.txt'); + + actual = findup('package.json', opts); + assert.basename(actual, 'package.json'); + assert.dirname(actual, 'test/fixtures/a/b/c/d/e/f/g'); + + actual = findup('one.txt', opts); + assert.basename(actual, 'one.txt'); + assert.dirname(actual, 'test/fixtures/a/b/c/d'); + + actual = findup('two.txt', opts); + assert.basename(actual, 'two.txt'); + assert.dirname(actual, 'test/fixtures/a/b/c'); + }); + + it('should return `null` when no files are found:', function() { + var dep = normalize(findup('*.foo', {cwd: path.dirname(resolve.sync('micromatch'))})); + assert.equal(dep, null); + assert.equal(findup('**/b*.json', {cwd: npm('is-glob')}), null); + assert.equal(findup('foo.json', {cwd: 'test/fixtures/a/b/c/d/e/f/g'}), null); + assert.equal(findup('foo.json', {cwd: 'test/fixtures/a/b/c/d/e/f/g', matchBase: true}), null); + }); + + it('should support finding file in immediate parent dir', function () { + cwd = path.resolve(__dirname, 'fixtures/a/b/c'); + var actual = findup('a.md', { cwd: cwd }); + assert.dirname(actual, path.dirname(cwd)); + assert.basename(actual, 'a.md'); + }); + + it('should support micromatch `nocase` option:', function () { + actual = findup('ONE.*', { cwd: 'test/fixtures/a/b/c/d' }); + assert.basename(actual, 'ONE.txt'); + assert.dirname(actual, 'test/fixtures/a/b/c'); + + actual = findup('ONE.*', { cwd: 'test/fixtures/a/b/c/d', nocase: true }); + assert.basename(actual, 'one.txt'); + assert.dirname(actual, 'test/fixtures/a/b/c/d'); + }); + + it('should find files from absolute paths:', function () { + var actual = findup('package.json', { cwd: __dirname }); + + assert.basename(actual, 'package.json'); + assert.dirname(actual, path.resolve(__dirname, '..')); + + actual = findup('one.txt', { cwd: __dirname + '/fixtures/a' }); + assert.basename(actual, 'one.txt'); + assert.dirname(actual, 'test/fixtures/a'); + + actual = findup('two.txt', { cwd: __dirname + '/fixtures/a/b/c' }); + assert.basename(actual, 'two.txt'); + assert.dirname(actual, 'test/fixtures/a/b/c'); + }); + + it('should find files in user home:', function () { + var actual = findup('*', { cwd: home() }); + assert.isPath(actual); + assert(exists(actual)); + assert.dirname(actual, home()); + }); + + it('should find files in user home using tilde expansion:', function () { + var actual = findup('*', { cwd: '~' }); + assert.isPath(actual); + assert(exists(actual)); + assert.dirname(actual, home()); + }); + + it('should match files in cwd before searching up', function() { + var actual = findup(['a.txt', 'a.md'], { cwd: __dirname + '/fixtures/a/b' }); + assert.basename(actual, 'a.md'); + assert.dirname(actual, 'test/fixtures/a/b'); + }); +}); diff -Nru node-findup-sync-0.1.3/.travis.yml node-findup-sync-0.4.3/.travis.yml --- node-findup-sync-0.1.3/.travis.yml 2014-03-14 14:30:26.000000000 +0000 +++ node-findup-sync-0.4.3/.travis.yml 2016-10-12 21:43:14.000000000 +0000 @@ -1,5 +1,15 @@ +sudo: false language: node_js +os: + - linux + - osx node_js: - - 0.8 -before_script: - - npm install -g grunt-cli + - "6" + - "5" + - "4" + - "0.12" + - "0.10" +matrix: + fast_finish: true + allow_failures: + - node_js: "0.10"