From 72c44b50fc5c8c6b0e156c293b7f0daf8d9b31eb Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 28 Dec 2018 16:06:41 -0700 Subject: [PATCH] Scaffold: Normalize repository --- .editorconfig | 13 ++ .eslintrc | 3 + .gitignore | 35 ++++- .jshintrc | 19 --- .npmrc | 1 + .travis.yml | 3 + LICENSE | 21 +++ LICENSE-MIT | 24 ---- README.md | 70 ++++----- appveyor.yml | 1 + index.js | 4 +- package.json | 37 +++-- test/.eslintrc | 3 + test/support/index.js | 45 +++--- test/test.js | 327 ++++++++++++++++++++++-------------------- 15 files changed, 329 insertions(+), 277 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 .npmrc create mode 100644 LICENSE delete mode 100644 LICENSE-MIT create mode 100644 test/.eslintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e000b0c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..a5a4a17 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "gulp" +} diff --git a/.gitignore b/.gitignore index cb5fd92..40e3eff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,32 @@ -*.DS_Store -*.sublime-* +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules -npm-debug.log -test/actual + +# Users Environment Variables +.lock-wscript + +# Garbage files +.DS_Store diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index a82080d..0000000 --- a/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "asi": false, - "boss": true, - "curly": true, - "eqeqeq": true, - "eqnull": true, - "esnext": true, - "immed": true, - "latedef": false, - "laxbreak": true, - "laxcomma": false, - "newcap": true, - "noarg": true, - "node": true, - "sub": true, - "undef": true, - "unused": true, - "mocha": true -} \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index 8df6093..9df5533 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,12 @@ os: - linux - osx node_js: + - "10" - "8" - "6" - "5" - "4" - "0.12" - "0.10" +after_script: + - npm run coveralls diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6e210d0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2018 Ben Alman , Blaine Bublitz , and Eric Schoffstall + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE-MIT b/LICENSE-MIT deleted file mode 100644 index 8bb6566..0000000 --- a/LICENSE-MIT +++ /dev/null @@ -1,24 +0,0 @@ -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 -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 58ce20e..3d1b17b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,17 @@ -# 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. -Matching is done with [micromatch][], please report any matching related issues on that repository. +# findup-sync -## Install with [npm](npmjs.org) +[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] -```bash -npm i findup-sync --save -``` +Find the first file matching a given pattern in the current directory or the nearest ancestor directory. + +Matching is done with [micromatch][micromatch], please report any matching related issues on that repository. ## Usage @@ -23,47 +26,32 @@ var filepath1 = findup('{a,b}*.txt'); var filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true}); ``` -* `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. - -## Running tests - -Install dev dependencies: - -```bash -npm i -d && npm test -``` +## API -## Contributing +### `findup(patterns, [options])` -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/) +* `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. -For bugs and feature requests, [please create an issue](https://github.com/cowboy/node-findup-sync/issues). +## License -## Release History +MIT -2017-08-07 - v2.0.0 - Drop node 0.8 support, Bump all dependencies (including some Majors) -2017-04-18 - v1.0.0 - Major bump from stable 0.4.3 -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. +[micromatch]: http://github.com/jonschlinkert/micromatch -## Authors +[downloads-image]: http://img.shields.io/npm/dm/findup-sync.svg +[npm-url]: https://www.npmjs.com/package/findup-sync +[npm-image]: http://img.shields.io/npm/v/findup-sync.svg -**"Cowboy" Ben Alman** - -+ [github/cowboy](https://github.com/cowboy) -+ [twitter/cowboy](http://twitter.com/cowboy) +[travis-url]: https://travis-ci.org/gulpjs/findup-sync +[travis-image]: http://img.shields.io/travis/gulpjs/findup-sync.svg?label=travis-ci -## License +[appveyor-url]: https://ci.appveyor.com/project/gulpjs/findup-sync +[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/findup-sync.svg?label=appveyor -Copyright (c) 2012-2016 "Cowboy" Ben Alman -Released under the MIT license +[coveralls-url]: https://coveralls.io/r/gulpjs/findup-sync +[coveralls-image]: http://img.shields.io/coveralls/gulpjs/findup-sync/master.svg -[micromatch]: http://github.com/jonschlinkert/micromatch +[gitter-url]: https://gitter.im/gulpjs/gulp +[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg diff --git a/appveyor.yml b/appveyor.yml index b86e50f..e416994 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,7 @@ environment: - nodejs_version: "5" - nodejs_version: "6" - nodejs_version: "8" + - nodejs_version: "10" install: - ps: Install-Product node $env:nodejs_version diff --git a/index.js b/index.js index b843495..2a9e117 100644 --- a/index.js +++ b/index.js @@ -80,6 +80,8 @@ function findFile(cwd, filename, options) { function tryReaddirSync(fp) { try { return fs.readdirSync(fp); - } catch(err) {} + } catch (err) { + // Ignore error + } return []; } diff --git a/package.json b/package.json index 435aa3a..de6f295 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,30 @@ { "name": "findup-sync", - "description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.", "version": "2.0.0", - "author": "\"Cowboy\" Ben Alman (http://benalman.com)", - "repository": "js-cli/node-findup-sync", - "license": "MIT", - "files": [ - "index.js" + "description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.", + "author": "Gulp Team (http://gulpjs.com/)", + "contributors": [ + "Ben Alman ", + "Tyler Kellen ", + "Jon Schlinkert ", + "Blaine Bublitz " ], - "main": "index.js", + "repository": "gulpjs/findup-sync", + "license": "MIT", "engines": { "node": ">= 0.10" }, + "main": "index.js", + "files": [ + "index.js", + "LICENSE" + ], "scripts": { - "lint": "jshint index.js test/support/index.js test/test.js", - "test": "npm run lint && mocha" + "lint": "eslint .", + "pretest": "npm run lint", + "test": "mocha --async-only", + "cover": "istanbul cover _mocha --report lcovonly", + "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "detect-file": "^1.0.0", @@ -23,10 +33,13 @@ "resolve-dir": "^1.0.1" }, "devDependencies": { + "eslint": "^2.13.0", + "eslint-config-gulp": "^3.0.1", + "expect": "^1.20.2", "homedir-polyfill": "^1.0.1", - "is-absolute": "^1.0.0", - "jshint": "^2.9.5", - "mocha": "^3.5.0", + "istanbul": "^0.4.3", + "istanbul-coveralls": "^1.0.3", + "mocha": "^3.5.3", "normalize-path": "^2.1.1", "resolve": "^1.4.0" }, diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..06b940f --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "gulp/test" +} diff --git a/test/support/index.js b/test/support/index.js index 399311b..485fa55 100644 --- a/test/support/index.js +++ b/test/support/index.js @@ -2,8 +2,8 @@ var path = require('path'); var normalizePath = require('normalize-path'); -var isAbsolute = require('is-absolute'); var resolve = require('resolve'); +var expect = require('expect'); exports.normalize = function(filepath) { return filepath ? normalizePath(path.relative('.', filepath)) : null; @@ -24,28 +24,25 @@ 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)); - }; +exports.expectExtras = { + isPath: function() { + var filepath = this.actual; + expect(filepath).toExist(); + expect(filepath).toBeA('string'); + return this; + }, + toHaveBasename: function(basename) { + var filepath = this.actual; + expect(filepath).toExist(); + expect(filepath).toBeA('string'); + expect(path.basename(filepath)).toEqual(basename); + return this; + }, + toHaveDirname: function(dirname) { + var filepath = this.actual; + expect(filepath).toExist(); + expect(filepath).toBeA('string'); + expect(path.dirname(path.resolve(filepath))).toEqual(path.resolve(dirname)); + }, }; diff --git a/test/test.js b/test/test.js index b847334..be17b2c 100644 --- a/test/test.js +++ b/test/test.js @@ -1,31 +1,36 @@ 'use strict'; -require('mocha'); var fs = require('fs'); var path = require('path'); -var assert = require('assert'); -var support = require('./support'); -support.assert(assert); + +var expect = require('expect'); var home = require('homedir-polyfill'); -var exists = fs.existsSync; var resolve = require('resolve'); + +var support = require('./support'); +expect.extend(support.expectExtras); + var findup = require('../'); + +var exists = fs.existsSync; var normalize = support.normalize; var chdir = support.chdir; var npm = support.npm; -var cwd; -var actual; var isLinux = process.platform === 'linux'; +var cwd, actual; +describe('findup-sync', function() { -describe('findup-sync', function () { - before(function () { + before(function(done) { fs.writeFileSync(home() + '/_aaa.txt', ''); fs.writeFileSync(home() + '/_bbb.txt', ''); + done(); }); - after(function () { + + after(function(done) { fs.unlinkSync(home() + '/_aaa.txt'); fs.unlinkSync(home() + '/_bbb.txt'); + done(); }); it('should throw when the first arg is not a string or array:', function(cb) { @@ -33,270 +38,288 @@ describe('findup-sync', function () { findup(); cb(new Error('expected an error')); } catch (err) { - assert.equal(err.message, 'findup-sync expects a string or array as the first argument.'); + expect(err.message).toEqual('findup-sync expects a string or array as the first argument.'); cb(); } }); - it('should work when no cwd is given', function () { + it('should work when no cwd is given', function(done) { 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'); + expect(actual).toExist(); + expect(actual).toHaveDirname(path.resolve(__dirname, '..')); + expect(actual).toHaveBasename('package.json'); + expect(normalize(findup('package.json'))).toEqual('package.json'); + done(); }); - it('should find files in a child directory', function () { + it('should find files in a child directory', function(done) { 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); + expect(actual).toExist(); + expect(exists(actual)).toExist(); + expect(actual).toEqual(expected); restore(); + done(); }); - it('should find case sensitive files in a child directory', function () { + it('should find case sensitive files in a child directory', function(done) { 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); + var actual = findup('a/b/mochafile.txt', { nocase: true }); + expect(actual).toExist(); + expect(exists(actual)).toExist(); + expect(actual).toEqual(expected); restore(); + done(); }); - it('should find files in a child directory relative to a cwd', function () { + it('should find files in a child directory relative to a cwd', function(done) { 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 actualFile = findup('a/b/file.txt', { cwd: 'a/b/c/d' }); + expect(actualFile).toExist(); + expect(exists(actualFile)).toExist(); + expect(actualFile).toEqual(expectedFile); - var actualA = findup('a.txt', {cwd: 'a/b/c/d/e/f'}); - assert(actualA); - assert(exists(actualA)); - assert.equal(actualA, expectedA); + var actualA = findup('a.txt', { cwd: 'a/b/c/d/e/f' }); + expect(actualA).toExist(); + expect(exists(actualA)).toExist(); + expect(actualA).toEqual(expectedA); tempDir(); + done(); }); - it('should find case sensitive files in a child directory relative to a cwd', function () { + it('should find case sensitive files in a child directory relative to a cwd', function(done) { 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 actualFile = findup('a/b/mochafile.txt', { cwd: 'a/b/c/d', nocase: true }); + expect(actualFile).toExist(); + expect(exists(actualFile)).toExist(); + expect(actualFile).toEqual(expectedFile); - var actualA = findup('a.txt', {cwd: 'a/b/c/d/e/f'}); - assert(actualA); - assert(exists(actualA)); - assert.equal(actualA, expectedA); + var actualA = findup('a.txt', { cwd: 'a/b/c/d/e/f' }); + expect(actualA).toExist(); + expect(exists(actualA)).toExist(); + expect(actualA).toEqual(expectedA); tempDir(); + done(); }); - 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'); + it('should support normal (non-glob) file paths:', function(done) { + var normPath = normalize(findup('package.json', { cwd: path.dirname(resolve.sync('normalize-path')) })); + expect(normPath).toEqual('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'); + var isGlob = normalize(findup('package.json', { cwd: path.dirname(resolve.sync('is-glob')) })); + expect(isGlob).toEqual('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'); + var actual = findup('package.json', { cwd: cwd }); + expect(actual).toHaveDirname(cwd); + expect(actual).toHaveBasename('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'); + actual = findup('c/package.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }); + expect(actual).toHaveBasename('package.json'); + expect(actual).toHaveDirname('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'); + actual = findup('package.json', { cwd: cwd }); + expect(actual).toHaveDirname(cwd); + expect(actual).toHaveBasename('package.json'); + done(); }); - 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 normal (non-glob) case sensitive file paths:', function(done) { + actual = findup('c/mochafile.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }); + expect(actual).toHaveBasename(isLinux ? 'Mochafile.txt' : 'mochafile.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + done(); }); - 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'); + it('should support glob patterns', function(done) { + expect(normalize(findup('**/c/package.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/package.json'); + expect(normalize(findup('**/one.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/d/one.txt'); + expect(normalize(findup('**/two.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('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 pkg = normalize(findup('p*.json', { cwd: npm('micromatch') })); + expect(pkg).toEqual('node_modules/micromatch/package.json'); - var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g'}; + 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'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('package.json'); actual = findup('c/package.json', opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'package.json'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('package.json'); actual = findup('**/ONE.txt', opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'ONE.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('ONE.txt'); actual = findup('**/two.txt', opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'two.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('two.txt'); cwd = npm('is-glob'); - actual = findup('p*.json', {cwd: cwd}); - assert.dirname(actual, cwd); - assert.basename(actual, 'package.json'); + actual = findup('p*.json', { cwd: cwd }); + expect(actual).toHaveDirname(cwd); + expect(actual).toHaveBasename('package.json'); + done(); }); - 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'); + it('should support case sensitive glob patterns', function(done) { + expect(normalize(findup('**/c/mochafile.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('test/fixtures/a/b/c/Mochafile.txt'); + expect(normalize(findup('**/one.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('test/fixtures/a/b/c/d/one.txt'); + expect(normalize(findup('**/two.txt', { cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true }))).toEqual('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'); + expect(normalize(findup('mocha*', { cwd: 'test/fixtures/a/b/c', nocase: true }))).toEqual('test/fixtures/a/b/c/Mochafile.txt'); - var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g', nocase: true}; + 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'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('Mochafile.txt'); actual = findup('c/mochafile.txt', opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, (isLinux ? 'Mochafile.txt' : 'mochafile.txt')); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename(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'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('ONE.txt'); actual = findup('**/two.txt', opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'two.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('two.txt'); + done(); }); - 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'); + it('should support arrays of glob patterns', function(done) { + expect(normalize(findup(['**/c/package.json'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/package.json'); + expect(normalize(findup(['**/one.txt'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/d/one.txt'); + expect(normalize(findup(['**/two.txt'], { cwd: 'test/fixtures/a/b/c/d/e/f/g' }))).toEqual('test/fixtures/a/b/c/two.txt'); - var opts = {cwd: 'test/fixtures/a/b/c/d/e/f/g'}; + 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'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('package.json'); actual = findup(['lslsl', 'c/package.json'], opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'package.json'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('package.json'); actual = findup(['lslsl', '**/ONE.txt'], opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'ONE.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('ONE.txt'); actual = findup(['lslsl', '**/two.txt'], opts); - assert.dirname(actual, 'test/fixtures/a/b/c'); - assert.basename(actual, 'two.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + expect(actual).toHaveBasename('two.txt'); actual = findup(['lslsl', '**/blah.txt'], opts); - assert(actual === null); + expect(actual === null).toExist(); cwd = npm('is-glob'); - actual = findup(['lslsl', 'p*.json'], {cwd: cwd}); - assert.dirname(actual, cwd); - assert.basename(actual, 'package.json'); + actual = findup(['lslsl', 'p*.json'], { cwd: cwd }); + expect(actual).toHaveDirname(cwd); + expect(actual).toHaveBasename('package.json'); + done(); }); - it('should support micromatch `matchBase` option:', function() { + it('should support micromatch `matchBase` option:', function(done) { 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'); + expect(normalize(findup('package.json', opts))).toEqual('test/fixtures/a/b/c/d/e/f/g/package.json'); + expect(normalize(findup('one.txt', opts))).toEqual('test/fixtures/a/b/c/d/one.txt'); + expect(normalize(findup('two.txt', opts))).toEqual('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'); + expect(actual).toHaveBasename('package.json'); + expect(actual).toHaveDirname('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'); + expect(actual).toHaveBasename('one.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c/d'); actual = findup('two.txt', opts); - assert.basename(actual, 'two.txt'); - assert.dirname(actual, 'test/fixtures/a/b/c'); + expect(actual).toHaveBasename('two.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + done(); }); - 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 return `null` when no files are found:', function(done) { + var dep = normalize(findup('*.foo', { cwd: path.dirname(resolve.sync('micromatch')) })); + expect(dep).toEqual(null); + expect(findup('**/b*.json', { cwd: npm('is-glob') })).toEqual(null); + expect(findup('foo.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g' })).toEqual(null); + expect(findup('foo.json', { cwd: 'test/fixtures/a/b/c/d/e/f/g', matchBase: true })).toEqual(null); + done(); }); - it('should support finding file in immediate parent dir', function () { + it('should support finding file in immediate parent dir', function(done) { 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'); + expect(actual).toHaveDirname(path.dirname(cwd)); + expect(actual).toHaveBasename('a.md'); + done(); }); - it('should support micromatch `nocase` option:', function () { + it('should support micromatch `nocase` option:', function(done) { actual = findup('ONE.*', { cwd: 'test/fixtures/a/b/c/d' }); - assert.basename(actual, 'ONE.txt'); - assert.dirname(actual, 'test/fixtures/a/b/c'); + expect(actual).toHaveBasename('ONE.txt'); + expect(actual).toHaveDirname('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'); + expect(actual).toHaveBasename('one.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c/d'); + done(); }); - it('should find files from absolute paths:', function () { + it('should find files from absolute paths:', function(done) { var actual = findup('package.json', { cwd: __dirname }); - assert.basename(actual, 'package.json'); - assert.dirname(actual, path.resolve(__dirname, '..')); + expect(actual).toHaveBasename('package.json'); + expect(actual).toHaveDirname(path.resolve(__dirname, '..')); actual = findup('one.txt', { cwd: __dirname + '/fixtures/a' }); - assert.basename(actual, 'one.txt'); - assert.dirname(actual, 'test/fixtures/a'); + expect(actual).toHaveBasename('one.txt'); + expect(actual).toHaveDirname('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'); + expect(actual).toHaveBasename('two.txt'); + expect(actual).toHaveDirname('test/fixtures/a/b/c'); + done(); }); - it('should find files in user home:', function () { + it('should find files in user home:', function(done) { var actual = findup('*', { cwd: home() }); - assert.isPath(actual); - assert(exists(actual)); - assert.dirname(actual, home()); + expect(actual).isPath(); + expect(exists(actual)).toExist(); + expect(actual).toHaveDirname(home()); + done(); }); - it('should find files in user home using tilde expansion:', function () { + it('should find files in user home using tilde expansion:', function(done) { var actual = findup('*', { cwd: '~' }); - assert.isPath(actual); - assert(exists(actual)); - assert.dirname(actual, home()); + expect(actual).isPath(); + expect(exists(actual)).toExist(); + expect(actual).toHaveDirname(home()); + done(); }); - it('should match files in cwd before searching up', function() { + it('should match files in cwd before searching up', function(done) { var actual = findup(['a.txt', 'a.md'], { cwd: __dirname + '/fixtures/a/b' }); - assert.basename(actual, 'a.md'); - assert.dirname(actual, 'test/fixtures/a/b'); + expect(actual).toHaveBasename('a.md'); + expect(actual).toHaveDirname('test/fixtures/a/b'); + done(); }); });