filing-cabinet
Find files based on partial paths
Last updated 8 years ago by mrjoelkemp .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install filing-cabinet 
SYNC missed versions from official npm registry.

filing-cabinet

CI npm version npm downloads

Get the file associated with a dependency/partial's path

npm install filing-cabinet

Usage

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

const 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',
  nodeModulesConfig: {
    entry: 'module'
  },
  tsConfig: 'path/to/tsconfig.json', // or an object
  tsConfigPath: 'path/to/tsconfig.json'
});

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. If exporting multiple configurations, the first configuration is used.
  • nodeModulesConfig: (optional) config for resolving entry file for node_modules. This value overrides the main attribute in the package.json file; used in conjunction with the packageFilter of the resolve package.
  • tsConfig: (optional) path to a TypeScript configuration. Could also be an object representing a pre-parsed TypeScript config.
  • tsConfigPath: (optional) A (virtual) path to TypeScript config file when tsConfig option is given as an object, not a string. Needed to calculate Path Mapping. If not given when tsConfig is an object, Path Mapping is ignored. This is not need when tsConfig is given as string (path to the tsconfig file).
  • noTypeDefinitions: (optional) For TypeScript files, whether to prefer *.js over *.d.ts.

Registered languages

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

  • JavaScript: CommonJS, AMD, ES6
  • TypeScript
  • CSS Preprocessors: Sass (.scss and .sass), Stylus (.styl), and Less (.less)

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.

CLI

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

filing-cabinet [options] <dependencyPath>

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

License

MIT

Current Tags

  • 5.0.2                                ...           latest (7 months ago)

76 Versions

  • 5.0.2                                ...           7 months ago
  • 5.0.1                                ...           7 months ago
  • 5.0.0                                ...           7 months ago
  • 4.2.0                                ...           7 months ago
  • 4.1.6                                ...           a year ago
  • 4.1.5                                ...           2 years ago
  • 4.1.4                                ...           2 years ago
  • 4.1.3                                ...           2 years ago
  • 4.1.2                                ...           2 years ago
  • 4.1.1                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.3.1                                ...           2 years ago
  • 3.3.0                                ...           3 years ago
  • 3.2.0                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           4 years ago
  • 2.6.0                                ...           4 years ago
  • 2.5.1                                ...           5 years ago
  • 2.5.0                                ...           5 years ago
  • 2.4.1                                ...           5 years ago
  • 2.3.3                                ...           5 years ago
  • 2.3.2                                ...           6 years ago
  • 2.3.1                                ...           6 years ago
  • 2.3.0                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.2                                ...           6 years ago
  • 2.1.1                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.3                                ...           6 years ago
  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.14.4                                ...           6 years ago
  • 1.14.3                                ...           6 years ago
  • 1.14.2                                ...           6 years ago
  • 1.14.1                                ...           6 years ago
  • 1.14.0                                ...           7 years ago
  • 1.13.1                                ...           7 years ago
  • 1.13.0                                ...           7 years ago
  • 1.12.0                                ...           7 years ago
  • 1.11.0                                ...           7 years ago
  • 1.10.0                                ...           7 years ago
  • 1.9.0                                ...           7 years ago
  • 1.8.0                                ...           8 years ago
  • 1.7.0                                ...           8 years ago
  • 1.6.1                                ...           8 years ago
  • 1.6.0                                ...           8 years ago
  • 1.5.2                                ...           8 years ago
  • 1.5.1                                ...           8 years ago
  • 1.5.0                                ...           8 years ago
  • 1.4.2                                ...           8 years ago
  • 1.4.1                                ...           8 years ago
  • 1.4.0                                ...           8 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.11                                ...           8 years ago
  • 1.2.10                                ...           8 years ago
  • 1.2.9                                ...           8 years ago
  • 1.2.8                                ...           8 years ago
  • 1.2.7                                ...           8 years ago
  • 1.2.6                                ...           8 years ago
  • 1.2.5                                ...           8 years ago
  • 1.2.4                                ...           8 years ago
  • 1.2.3                                ...           8 years ago
  • 1.2.2                                ...           8 years ago
  • 1.2.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.6                                ...           9 years ago
  • 1.0.5                                ...           9 years ago
  • 1.0.4                                ...           9 years ago
  • 1.0.3                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (10)
Dev Dependencies (7)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE