filing-cabinet v5.0.3
filing-cabinet
Get the file associated with a dependency/partial's path
npm install filing-cabinetUsage
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/somePartialPathpartial: the dependency path- This could be in any of the registered languages
directory: the path to all filesfilename: the path to the file containing thepartialast: (optional) the parsed AST forfilename.- Useful optimization for avoiding a parse of filename
config: (optional) requirejs config for resolving aliased JavaScript moduleswebpackConfig: (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 themainattribute in the package.json file; used in conjunction with the packageFilter of theresolvepackage.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 whentsConfigoption is given as an object, not a string. Needed to calculate Path Mapping. If not given whentsConfigis an object, Path Mapping is ignored. This is not need whentsConfigis given as string (path to the tsconfig file).noTypeDefinitions: (optional) For TypeScript files, whether to prefer*.jsover*.d.ts.
Registered languages
By default, filing-cabinet provides support for the following languages:
- JavaScript: CommonJS, AMD, ES6
- TypeScript
- CSS Preprocessors: Sass (
.scssand.sass), Stylus (.styl), and Less (.less) - Vue
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:partialfilenamedirectoryconfig
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
9 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago