1.1.0 • Published 4 years ago

node-file-navigator v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Node file navigator

Build Status

This simple application will enable you to navigate through a directory; recursively if required, filtering files and directories and applying custom processing on the file selected.

Required

Stable NodeJS version

Dependencies

None

How to add to your application

Add this module to your application as a dependency

npm i node-file-navigator
const fileNavigator = require('node-file-navigator');

API Reference

Method invocation

fileNavigator({ directory, fileSkipPattern, isRecursive, directorySkipPattern, callback, ...other })

Paramaters

ParameterTypeUsageExample
direcortyStringdirectory for navigation'/user/home/app'
fileSkipPatternFunction : ({ path, stat })If returns true processing of the file is skipped({path}) => (/.css$/.test(path))
isRecursiveBooleanshould navigate nested directoriestrue
directorySkipPatternFunction : ({ path, stat })If returns true navigation of the directory is skipped({path}) => (/node_modules$/.test(path))
callbackFunction: ({ path, stat})Define the file opration({ path }) => { console.log(path); }
otherObjectN/AN/A

Example

/**
 * An application to navigate through all .js files in the working directory
 * and nested directories and print the paths in the terminal without going through node_modules folder.
 *
*/
// Import 
const fileNavigator = require('node-file-navigator');

const directory = __dirname;
const fileSkipPattern = ({ path }) => !/.js$/.test(path);
const isRecursive = true;
const directorySkipPattern = ({ path }) => /node_modules/.test(path);
const callback = ({ path }) => { console.log(path); }

// Invoke
await fileNavigator({ directory, fileSkipPattern, isRecursive, directorySkipPattern, callback });
1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago