Socket
Socket
Sign inDemoInstall

dir-glob

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.2.0

13

index.js
'use strict';
const path = require('path');
const arrify = require('arrify');
const pathType = require('path-type');
const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
const getPath = filepath => filepath[0] === '!' ? filepath.slice(1) : filepath;
const getPath = (filepath, cwd) => path.join(cwd, filepath[0] === '!' ? filepath.slice(1) : filepath);

@@ -18,4 +17,2 @@ const addExtensions = (file, extensions) => {

const getGlob = (dir, opts) => {
opts = Object.assign({}, opts);
if (opts.files && !Array.isArray(opts.files)) {

@@ -41,3 +38,5 @@ throw new TypeError(`\`options.files\` must be an \`Array\`, not \`${typeof opts.files}\``);

module.exports = (input, opts) => {
return Promise.all(arrify(input).map(x => pathType.dir(getPath(x))
opts = Object.assign({cwd: process.cwd()}, opts);
return Promise.all([].concat(input).map(x => pathType.dir(getPath(x, opts.cwd))
.then(isDir => isDir ? getGlob(x, opts) : x)))

@@ -48,4 +47,6 @@ .then(globs => [].concat.apply([], globs));

module.exports.sync = (input, opts) => {
const globs = arrify(input).map(x => pathType.dirSync(getPath(x)) ? getGlob(x, opts) : x);
opts = Object.assign({cwd: process.cwd()}, opts);
const globs = [].concat(input).map(x => pathType.dirSync(getPath(x, opts.cwd)) ? getGlob(x, opts) : x);
return [].concat.apply([], globs);
};
{
"name": "dir-glob",
"version": "2.0.0",
"version": "2.2.0",
"description": "Convert directories to glob compatible strings",

@@ -29,3 +29,2 @@ "license": "MIT",

"dependencies": {
"arrify": "^1.0.1",
"path-type": "^3.0.0"

@@ -32,0 +31,0 @@ },

@@ -23,2 +23,9 @@ # dir-glob [![Build Status](https://travis-ci.org/kevva/dir-glob.svg?branch=master)](https://travis-ci.org/kevva/dir-glob)

dirGlob(['index.js', 'inner_folder'], {
cwd: 'fixtures'
}).then(files => {
console.log(files);
//=> ['index.js', 'inner_folder/**']
});
dirGlob(['lib/**', 'fixtures'], {

@@ -72,5 +79,11 @@ files: ['test', 'unicorn']

##### cwd
Type: `string`
Test in specific directory.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc