How to use the node-dir.files function in node-dir

To help you get started, we’ve selected a few node-dir 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 mdn / bob / lib / utils.js View on Github external
function copyDirectory(sourceDir, destDir) {
    // gather all files in sourceDir
    dir.files(sourceDir, function(err, files) {
        if (err) {
            if (err.code === 'ENOENT' && err.path === sourceDir) {
                console.error(
                    'Specified directory "' +
                        sourceDir +
                        '" does not exist. \nPlease specify an existing directory relative to the root of the project.'
                );
                return;
            }

            console.error('Error reading file list', err);
            throw err;
        }

        // Do not copy .DS_Store files
        files.filter(function(file) {
github lazojs / lazo / lib / server / resolver / file.js View on Github external
fs.exists(directory, function (exists) {
                if (!exists) {
                    return callback(null, []);
                }

                dir.files(directory, function (err, files) {
                    if (err) { // TODO: error handling
                        throw err;
                    }

                    if (!options.basePath && !options.ext) {
                        return files;
                    }

                    for (var i = 0; i < files.length; i++) {
                        if (options.ext && path.extname(files[i]) !== options.ext) {
                            continue;
                        }
                        files[i] = options.basePath ? files[i].replace(options.basePath + '/', '') : files[i];
                        filtered.push(files[i]);
                    }
github Dudemullet / tenna / routes / videos.js View on Github external
var getMovies = function(cb) {
        var videoList = [];

        //Recursively get all files in dir
        dirExp.files(movieDir, function(err,files) {
            if(!files)
                return cb(videoList);

            // Get supported files with valid extensions (mp4, avi, etc...)
            var filteredVideos = files.filter(validExtensionsFilter);

            //Per video, construct a useful video object
            filteredVideos.forEach(function(val,i,arr){
                videoList.push(newVideo(val, movieDir));
            });

            cb(videoList);
        });
    }
github GladysAssistant / Gladys / api / services / MusicService.js View on Github external
var size;

		// check if the importation is finished
		/**
		 * Description
		 * @method checkIfDone
		 * @return 
		 */
		function checkIfDone(){
			inserted++;
			if(inserted >= size)
				callback(null);
		}

		// get recursively all the files in the folder
		dir.files(sails.config.music.folder, function(err, files) {
			if(err) return sails.log.warn(err);

			if(files){

				size = files.length;

			   	for(var i=0;i
github ging / ediphy / webpack_plugins / bundle_zip_plugin.js View on Github external
fs.stat(path, function(err, stats) {
                    if(err) {
                        console.error("/dist/manifest_files/ does not exist!");
                        callback(null, "manifest_files");
                    }else{
                        dir.files(path, function(err, filelist) {
                            if (err) {throw err;}
                            async.each(filelist, function(elem, call) {
                                scorm_zip.file(elem.replace("dist\/lib\/scorm\/manifest_files/", ""), fs.readFileSync("./" + elem));
                                call();
                            }, function(err, results) {
                                callback(null, "manifest_files");
                            });
                        });
                    }
                });
            },
github Dudemullet / tenna / routes / file_routes.js View on Github external
var getFilesAtDir = function(dir, callback) {
        var fObjs = [];
        
        dirExp.files(dir, function(err,files) { if(err) console.log(err);
            if(!files)
                return callback({'files':fObjs});

            var filteredFiles = files.filter(validExtensionsFilter);

            filteredFiles.forEach(function(val, i, arr){
                arr[i] = val;
                fObjs.push({
                    name:val.substr(0,val.lastIndexOf(".")),
                    path: videoDir+val
                });
            });
            
            callback({"files":fObjs});
        });
    }
github ging / ediphy / webpack_plugins / bundle_zip_plugin.js View on Github external
fs.stat(path, function(err, stats) {
                    if(err) {
                        console.error("/dist/exercises/ does not exist!");
                        callback(null, "exercises");
                    }else{
                        dir.files(path, function(err, filelist) {
                            if (err) {throw err;}
                            async.each(filelist, function(elem, call) {
                                visor_zip.file(purgeRoot(elem), fs.readFileSync("./" + elem));
                                scorm_zip.file(purgeRoot(elem), fs.readFileSync("./" + elem));
                                call();
                            }, function(err, results) {
                                callback(null, "exercises");
                            });
                        });
                    }
                });
            },
github trufflesuite / ethpm-js / lib / sources.js View on Github external
return new Promise(function(accept, reject) {
      dir.files(source_path, function(err, files) {
        if (err) return reject(err);
        accept(files);
      });
    });
  },
github pouladzade / snak / libs / project.js View on Github external
return new Promise(function (fulfil, reject) {
      var dir = require('node-dir')
      var path = require('path')
      try {
        let dirPath = Schema.project_path + Schema.contracts
        dir.files(dirPath, function (err, files) {
          if (err) reject(err)

          files = files.filter(function (file) {
            return path.extname(file) == '.sol' && path.basename(file)[0] != '.'
          })
          if (files.length == 0) { reject('There is no .sol file in this directory!!') }

          fulfil(files)
        })
      } catch (ex) {
        reject(ex)
      }
    })
  }

node-dir

asynchronous file and directory operations for Node.js

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis