mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 15:23:47 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
99
node_modules/findup-sync/index.js
generated
vendored
Normal file
99
node_modules/findup-sync/index.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
'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) {
|
||||
if (typeof patterns === 'string') {
|
||||
return lookup(patterns, options);
|
||||
}
|
||||
|
||||
if (!Array.isArray(patterns)) {
|
||||
throw new TypeError('findup-sync expects a string or array as the first argument.');
|
||||
}
|
||||
|
||||
var len = patterns.length;
|
||||
var idx = -1;
|
||||
|
||||
while (++idx < len) {
|
||||
var res = lookup(patterns[idx], options);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
function lookup(pattern, options) {
|
||||
options = options || {};
|
||||
var cwd = path.resolve(resolveDir(options.cwd || ''));
|
||||
if (isGlob(pattern)) {
|
||||
return matchFile(cwd, pattern, options);
|
||||
} else {
|
||||
return findFile(cwd, pattern, 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;
|
||||
}
|
||||
}
|
||||
|
||||
var dir = path.dirname(cwd);
|
||||
if (dir === cwd) {
|
||||
return null;
|
||||
}
|
||||
return matchFile(dir, pattern, opts);
|
||||
}
|
||||
|
||||
function findFile(cwd, filename, options) {
|
||||
var res;
|
||||
var fp = cwd ? path.resolve(cwd, filename) : filename;
|
||||
if (res = detect(fp, options)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
var segs = cwd.split(path.sep);
|
||||
var len = segs.length;
|
||||
|
||||
while (len--) {
|
||||
cwd = segs.slice(0, len).join(path.sep);
|
||||
fp = path.resolve(cwd, filename);
|
||||
if (res = detect(fp, options)) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function tryReaddirSync(fp) {
|
||||
try {
|
||||
return fs.readdirSync(fp);
|
||||
} catch(err) {}
|
||||
return [];
|
||||
}
|
||||
50
node_modules/findup-sync/package.json
generated
vendored
Normal file
50
node_modules/findup-sync/package.json
generated
vendored
Normal file
@@ -0,0 +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.4.2",
|
||||
"homepage": "https://github.com/cowboy/node-findup-sync",
|
||||
"author": "\"Cowboy\" Ben Alman (http://benalman.com)",
|
||||
"repository": "cowboy/node-findup-sync",
|
||||
"bugs": {
|
||||
"url": "https://github.com/cowboy/node-findup-sync/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt && mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"detect-file": "^0.1.0",
|
||||
"is-glob": "^2.0.1",
|
||||
"micromatch": "^2.3.7",
|
||||
"resolve-dir": "^0.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"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",
|
||||
"match",
|
||||
"pattern",
|
||||
"resolve",
|
||||
"search"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user