Files
NapCatQQ/.pnpm-store/v3/files/1f/b8fb50a46e2c731e0da13c2acda838a0303d09594b58acae25080fb022a1914fec5e8c2f2715ede80031b6287c11af77e9370958bee2e5620ddf19d0a6b9c6
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

71 lines
1.7 KiB
Plaintext

'use strict';
var path = require('path');
var isNegated = require('is-negated-glob');
var isAbsolute = require('is-absolute');
module.exports = function(glob, options) {
// default options
var opts = options || {};
// ensure cwd is absolute
var cwd = path.resolve(opts.cwd ? opts.cwd : process.cwd());
cwd = unixify(cwd);
var rootDir = opts.root;
// if `options.root` is defined, ensure it's absolute
if (rootDir) {
rootDir = unixify(rootDir);
if (process.platform === 'win32' || !isAbsolute(rootDir)) {
rootDir = unixify(path.resolve(rootDir));
}
}
// trim starting ./ from glob patterns
if (glob.slice(0, 2) === './') {
glob = glob.slice(2);
}
// when the glob pattern is only a . use an empty string
if (glob.length === 1 && glob === '.') {
glob = '';
}
// store last character before glob is modified
var suffix = glob.slice(-1);
// check to see if glob is negated (and not a leading negated-extglob)
var ing = isNegated(glob);
glob = ing.pattern;
// make glob absolute
if (rootDir && glob.charAt(0) === '/') {
glob = join(rootDir, glob);
} else if (!isAbsolute(glob) || glob.slice(0, 1) === '\\') {
glob = join(cwd, glob);
}
// if glob had a trailing `/`, re-add it now in case it was removed
if (suffix === '/' && glob.slice(-1) !== '/') {
glob += '/';
}
// re-add leading `!` if it was removed
return ing.negated ? '!' + glob : glob;
};
function unixify(filepath) {
return filepath.replace(/\\/g, '/');
}
function join(dir, glob) {
if (dir.charAt(dir.length - 1) === '/') {
dir = dir.slice(0, -1);
}
if (glob.charAt(0) === '/') {
glob = glob.slice(1);
}
if (!glob) return dir;
return dir + '/' + glob;
}