New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grob-files

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grob-files

Find files with special suffix in one or many folders

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Install

$ npm install --save find-file

Usage

const Grob = require('find-file');
const mdfiles = Grob.getFiles(["./filelists"],'md',true);
//Then you will get all markdown files

Parameters

(1)source

The first paramter is source folder to search file with special suffix. It can be an array or an object. When it is an object ,we will only care about value of object while key is omitted!

(2)suffix

To search file with this suffix, such as "md" or "js/jsx" and so on.

(3)isObject

When this one is set true, then we will get something like bellow with file structure of this:

{ filelists:
   { hello: 'filelists/hello.md',
     index: 'filelists/index.md',
     md:
      { fol: { 
        index: 'filelists/md/fol/index.md'
         },
        index: 'filelists/md/index.md' 
     }
 }
}

When this paramter is false, we will get something like that:

[ 'filelists/hello.md',
  'filelists/index.md',
  'filelists/md/fol/index.md',
  'filelists/md/index.md',
]

API

(1)getFiles

Get files with special suffix

(2)traverse

Get filename with path prefixed , it is a inverse operation of getFiles.

Grob.traverse(files,function(filename){
  if(!filename)
  console.log(filename);
 //  filelists/hello.md
  // filelists/index.md
  // filelists/md/fol/index.md
  // filelists/md/index.md
})

(3)getRequiredFile(source,suffix)

Source and suffix as described above. Invoke this method you will get something like bellow:

 {
  'filelists': {
    'hello': require('C:/Users/Administrator/Desktop/find-files/filelists/hello.md'),
    'index': require('C:/Users/Administrator/Desktop/find-files/filelists/index.md'),
    'md': {
      'fol': {
        'index': require('C:/Users/Administrator/Desktop/find-files/filelists/md/fol/index.md')
      },
      'index': require('C:/Users/Administrator/Desktop/find-files/filelists/md/index.md')
    }
  }
}

Keywords

FAQs

Package last updated on 05 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc