Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const options = {
'hostname': req.hostname,
'path': path,
'includeBody': includeBody,
'possibleRDFType': possibleRDFType,
'range': req.headers.range,
'contentType': req.headers.accept
}
let ret
try {
ret = await ldp.get(options, req.accepts(['html', 'turtle', 'rdf+xml', 'n3', 'ld+json']) === 'html')
} catch (err) {
// use globHandler if magic is detected
if (err.status === 404 && glob.hasMagic(path)) {
debug('forwarding to glob request')
return globHandler(req, res, next)
} else {
debug(req.method + ' -- Error: ' + err.status + ' ' + err.message)
return next(err)
}
}
let stream
let contentType
let container
let contentRange
let chunksize
if (ret) {
stream = ret.stream
async function findContractFiles(pattern) {
// pattern is either a directory (contracts directory), or an absolute path
// with a glob expression
if (!glob.hasMagic(pattern))
pattern = path.join(pattern, DEFAULT_PATTERN)
const globOptions = {
follow: true, // follow symlinks
}
return globPromise(pattern, globOptions)
}
i = list.length-1;
while( i > -1) {
if (!minimatch(path.relative(options.cwd, list[i]), pattern)) {
list.splice(i,1);
}
i--;
}
}
else {
var newList = glob.sync(pattern, options);
// no files returned
if (!newList.length) {
// don't pass the file to the process script if it's a glob pattern
if (!glob.hasMagic(pattern)) {
list.push(pattern);
}
}
newList.forEach(function(item){
item = path.resolve(options.cwd, item);
if (list.indexOf(item)===-1) {
list.push(item);
}
});
}
});
function resolveGlob(workingDirectory: string, pattern: string): string[] {
// 'glob.sync()' does not resolve paths, only glob patterns
if (glob.hasMagic(pattern)) {
return glob
.sync(pattern, { cwd: workingDirectory })
.map((matchingPath) => path.resolve(workingDirectory, matchingPath));
}
const resolvedPath = path.resolve(workingDirectory, pattern);
return fs.existsSync(resolvedPath) ? [resolvedPath] : [];
}
patterns.forEach(pattern => {
if (glob.hasMagic(pattern)) {
paths.push(...glob.sync(pattern));
} else if (fs.existsSync(pattern)) {
paths.push(pattern);
}
});
return paths;
function rimrafSync (p, options) {
options = options || {}
defaults(options)
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert(options, 'rimraf: missing options')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
var results
if (options.disableGlob || !glob.hasMagic(p)) {
results = [p]
} else {
try {
options.lstatSync(p)
results = [p]
} catch (er) {
results = glob.sync(p, options.glob)
}
}
if (!results.length)
return
for (var i = 0; i < results.length; i++) {
var p = results[i]
export function expandFiles(patterns?: string[] | string) {
if (!patterns) {
patterns = [];
} else if (!Array.isArray(patterns)) {
patterns = [patterns];
}
const excludes: string[] = [];
const includes: string[] = [];
const paths: string[] = [];
for (let pattern of patterns) {
if (pattern[0] === '!') {
excludes.push(pattern.slice(1));
} else {
if (hasMagic(pattern)) {
includes.push(pattern);
} else {
paths.push(pattern);
}
}
}
const allPaths = includes
.map(pattern => glob(pattern, { ignore: excludes }))
.reduce((allFiles, files) => allFiles.concat(files), paths);
const uniquePaths: { [name: string]: boolean } = {};
allPaths.forEach(path => (uniquePaths[path] = true));
return Object.keys(uniquePaths);
}
options = {}
}
assert(p, 'rimraf: missing path')
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
assert(options, 'rimraf: invalid options argument provided')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
defaults(options)
var busyTries = 0
var errState = null
var n = 0
if (options.disableGlob || !glob.hasMagic(p))
return afterGlob(null, [p])
options.lstat(p, function (er, stat) {
if (!er)
return afterGlob(null, [p])
glob(p, options.glob, afterGlob)
})
function next (er) {
errState = errState || er
if (--n === 0)
cb(errState)
}
function afterGlob (er, results) {
.map(path => {
if (globHasMagic(path)) {
return globSync(path);
} else {
return path;
}
})
.reduce((a, b) => {
public static resolveFilePatterns(
patterns: string[]|string, opt_omitWarnings?: boolean, opt_relativeTo?: string): string[] {
let resolvedFiles: string[] = [];
let cwd = opt_relativeTo || process.cwd();
patterns = (typeof patterns === 'string') ? [patterns] : patterns;
if (patterns) {
for (let fileName of patterns) {
let matches = glob.hasMagic(fileName) ? glob.sync(fileName, {cwd}) : [fileName];
if (!matches.length && !opt_omitWarnings) {
logger.warn('pattern ' + fileName + ' did not match any files.');
}
for (let match of matches) {
let resolvedPath = path.resolve(cwd, match);
resolvedFiles.push(resolvedPath);
}
}
}
return resolvedFiles;
}