Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filing-cabinet

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filing-cabinet

Find files based on partial paths

  • 1.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
918K
decreased by-2.61%
Maintainers
1
Weekly downloads
 
Created
Source

filing-cabinet npm npm

Look up a filename based on a partial path

npm install --save filing-cabinet

Usage


var cabinet = require('filing-cabinet');

var result = cabinet({
  partial: 'somePartialPath',
  directory: 'path/to/all/files',
  filename: 'path/to/parent/file',
  ast: {}, // an optional AST representation of `filename`
  // Only for JavaScript files
  config: 'path/to/requirejs/config',
  webpackConfig: 'path/to/webpack/config'
});

console.log(result); // /absolute/path/to/somePartialPath
  • partial: the dependency path
  • This could be in any of the registered languages
  • directory: the path to all files
  • filename: the path to the file containing the partial
  • ast: (optional) the parsed AST for filename.
  • Useful optimization for avoiding a parse of filename
  • config: (optional) requirejs config for resolving aliased JavaScript modules
  • webpackConfig: (optional) webpack config for resolving aliased JavaScript modules

Registered languages

By default, filing-cabinet provides support for the following languages:

  • JavaScript (all files with the .js extension)
  • Sass (.scss and .sass)
  • Stylus (.styl)

You can register resolvers for new languages via cabinet.register(extension, resolver).

  • extension: the extension of the file that should use the custom resolver (ex: '.py', '.php')
  • resolver: a function that accepts the following (ordered) arguments that were given to cabinet:
    • partial
    • filename
    • directory
    • config

For examples of resolver implementations, take a look at the default language resolvers:

If a given extension does not have a registered resolver, cabinet will use a generic file resolver which is basically require('path').join with a bit of extension defaulting logic.

Shell script

  • Requires a global install npm install -g filing-cabinet

filing-cabinet [options] <dependencyPath>

  • See filing-cabinet --help for details on the options

Keywords

FAQs

Package last updated on 02 Sep 2016

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