Socket
Book a DemoInstallSign in
Socket

dir-files

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-files

micro library to get files from a path with middlewares

1.0.0-rc.15
latest
Source
npmnpm
Version published
Weekly downloads
51
-26.09%
Maintainers
2
Weekly downloads
 
Created
Source

dir-files

Example: examples/recursive.js

var path = require('path');
var dirFiles = require('../dist/dir-files');

var dfp = dirFiles.plugins;
var pluginOpt = {};

dirFiles({
	path: path.join(__dirname, '..'),
	plugins: [
		dfp.skip(function skipSpecial(file) {
			var name = file.name;
			// example of manual skipping
			var charZero = name.charAt(0);
			var skip = ('.' === charZero) ||
				('$' === charZero) ||
				('node_modules' === name);
			return skip;
		}),
		dfp.stat(pluginOpt),
		dfp.queueDir(pluginOpt),
		dfp.readDir(pluginOpt),
		dfp.queueDirFiles(pluginOpt),
		dfp.skip(function skipEmptyNameOrDir(file) {
			return !file.name || file.stat.isDirectory();
		}),
		function printFile(file) {
			console.log('~ '+path.join(file.dir.sub, file.name));
		}
	],
	callback: function(err) {
		if (err) throw err;
	}
});

Output:

~ README.md
~ dist/dir-files.esm.js
~ dist/dir-files.js
~ dist/test/index_test.js
~ examples/cli.js
~ examples/dynamic.js
~ examples/recursive.js
~ lib/index.js
~ lib/plugins/glob.js
~ lib/plugins/queue-dir-files.js
~ lib/plugins/queue-dir.js
~ lib/plugins/read-dir.js
~ lib/plugins/skip.js
~ lib/plugins/stat.js
~ lib/time-plugins.js
~ package.json
~ rollup.config.js
~ rollup.config.test.js
~ test/index_test.esm.js
~ test/istanbul.reporter.js
~ test/mocha.opts

Keywords

dir

FAQs

Package last updated on 07 Mar 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.