0.0.1 • Published 4 years ago

path-scanner v0.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

filescan

Search for files

Example

const FileScan = require('filescan')
const Path = require('path')

const scannedPath = '../'

FileScan.scanDirectory(
	// Path to scan
	scannedPath,
	// Function that can prevent scan in some directories
	directory => {
		if (directory.includes('node_modules')) {
			return false
		}
		return true
	}
).then(files => {
	const jsFiles = files
		// Filter the results on certain file extension e.g. (optional)
		.filter(filePath => /\**\.js$/.test(filePath))
		// Resolve path to get absolute path (optional)
		.map(filePath => Path.resolve(scannedPath, filePath))
	console.log(jsFiles)
})