How to use the safefs.readdir function in safefs

To help you get started, we’ve selected a few safefs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bevry / watchr / source / index.js View on Github external
// Set this sub group to execute in parallel
			this.setConfig({ concurrency: 0 })

			// So let's check if we are a directory
			if (currentStat.isDirectory() === false) {
				// If we are a file, lets simply emit the change event
				this.log('debug', `watch emit update: ${this.path}`)
				this.emit('change', 'update', this.path, currentStat, previousStat)
				return done()
			}

			// We are a direcotry
			// Chances are something actually happened to a child (rename or delete)
			// and if we are the same, then we should scan our children to look for renames and deletes
			fsUtil.readdir(this.path, (err, newFileRelativePaths) => {
				// Error?
				if (err) return done(err)

				// Log
				this.log('debug', `watch read dir: ${this.path}`, newFileRelativePaths)

				// Find deleted files
				eachr(this.children, (child, childFileRelativePath) => {
					// Skip if the file still exists
					if (newFileRelativePaths.indexOf(childFileRelativePath) !== -1) return

					// Fetch full path
					const childFileFullPath = pathUtil.join(
						this.path,
						childFileRelativePath
					)
github bevry / projectz / source / lib / projectz.js View on Github external
tasks.addTask(complete => {
			readdir(this.cwd, (err, files) => {
				if (err) return complete(err)
				files.forEach(file => {
					const filePath = join(this.cwd, file)

					packages.forEach(key => {
						const basename = file
							.toLowerCase()
							.split('.')
							.slice(0, -1)
							.join('.')
						if (basename === key) {
							const message = `Reading package file: ${filePath}`
							tasks.addTask(message, complete => {
								this.log('info', message)
								CSON.readFile(filePath, (err, data) => {
									if (err) return complete(err)

safefs

Stop getting EMFILE errors! Open only as many files as the operating system supports.

Artistic-2.0
Latest version published 10 months ago

Package Health Score

63 / 100
Full package analysis