How to use the files function from node-dir
Find comprehensive JavaScript node-dir.files code examples handpicked from public code repositorys.
186 187 188 189 190 191 192 193 194 195
/** * Make data of navigation and search keywords */ function makeNavAndSearchData() { const files = nodedir.files(EXAMPLE_FILES_PATH, { sync: true }); files.forEach((file) => { if (file.match(/.html$/)) { const filename = getFileName(file);
15
100
13
GitHub: tronprotocol/tronbox
99 100 101 102 103 104 105 106 107
const Migrate = { Migration: Migration, assemble: function (options, callback) { dir.files(options.migrations_directory, function (err, files) { if (err) return callback(err); options.allowed_extensions = options.allowed_extensions || /^\.(js|es6?)$/;
65
99
9
GitHub: danjm/Git-what-we-MEAN
44 45 46 47 48 49 50 51 52 53
conn.close(); }) }); /*Clean out the jsonData dir*/ nodeDir.files(dir, function(err, files) { if (err) throw err; for(var x = 0; x < files.length; x++){ fs.unlinkSync(files[x]); }
5
12
2
373 374 375 376 377 378 379 380 381 382 383
}) } const files = (rootdir) => new Promise((resolve, reject) => { dir.files(rootdir, (err, files) => { if (err) reject(err) resolve(files) }) })
4
13
0
+ 4 other calls in file
GitHub: stephentuso/pubxml
109 110 111 112 113 114 115 116 117 118
* filenames as names */ function processResourceFolder (path, callback) { const dirName = getLastPathComponent(path) const resType = dirName.split('-')[0] dir.files(path, function (err, files) { if (err) throw err for (let i = 0; i < files.length; i++) { if (files[i].match(/\.xml$/i)) { const name = getLastPathComponent(files[i]).split('.xml')[0]
2
6
0
64 65 66 67 68 69 70 71 72 73
reject(err); } resolve(result); }; } dir.files(sourceDir, function(err, files){ if (err) { callback(err); } if(files === undefined) {
2
3
0
100 101 102 103 104 105 106 107 108 109
return newList; } function getFiles( mediaPath, order ) { let mediaFiles = dir.files( mediaPath, {sync:true, recursive:false}); let matchs = [/.mp4$/ig, /.rmvb$/ig, /.mkv$/ig]; let isMediaFile = function(filename) { return matchs.some( regex => {
0
2
1
676 677 678 679 680 681 682 683 684 685
files: [ (next) => { // recurse into all directories to get complete list of files let files = specificFiles || []; async.each(directories, (directory, eachNext) => { dir.files(directory, (err, dirFiles) => { files = files.concat(dirFiles || []); eachNext(err); }); }, (err) => {
1
1
0
GitHub: pinkf88/ofa_public
131 132 133 134 135 136 137 138 139 140 141 142
var last_datum = datum; var files_all = null; try { files_all = dir.files(PFAD_SOURCE, { sync: true }); } catch(err) { console.log(colors.yellow('Keine Dateien in ' + PFAD_SOURCE + ' vorhanden.')); console.log(err.message);
0
0
1
+ 7 other calls in file
GitHub: pinkf88/ofa_public
132 133 134 135 136 137 138 139 140 141 142 143
// var picsdirectory = '../pics/'; var files_all = null; try { files_all = dir.files(picsdirectory, { sync: true, recursive: false }); } catch(err) { console.log(picsdirectory + ' nicht vorhanden.') console.log(err.message);
0
0
1
+ 7 other calls in file
347 348 349 350 351 352 353 354 355 356 357
function getPathList (dir, fileMatch, nameMap) { Expect(dir).is.a.String('gPL dir'); Expect(fileMatch).is.a.String('gPL filematch'); return new Promise((resolve, reject) => { Dir.files(dir, (err, pathList) => { if (err) reject(err); let match = new RegExp(fileMatch); let filtered = _.filter(pathList, path => { let filename = Path.basename(path);
0
0
2
+ 11 other calls in file
GitHub: kulboyIT/homehost
172 173 174 175 176 177 178 179 180 181
var re = new RegExp(/(\d+)(.mp4|.mkv)$/); // movie_id json = { movies: [] }; console.log('Generating data for Movies...') node_dir.files(config.movies.path, function(err, files) { if (err) throw err; bluebird.mapSeries(files, function(file){ console.log('GET: ' + file);
0
0
0
+ 3 other calls in file
GitHub: rbsoen/server-test
29 30 31 32 33 34 35 36 37 38
// init response array let objects = []; // int subdir array subdirs = subdirs.split("/"); // iterate through every file dir.files( path.resolve.apply(null, subdirs), function(err, files) { if (err) {console.error(err)}; // rethrow error let file; for (file of files) {
0
0
0
GitHub: twobucks/isused
19 20 21 22 23 24 25 26 27 28 29
}) } function traverseFolders(folder) { return new Promise((resolve, reject) => { dir.files(folder, (err, files) => { if (err) { reject(err) } return Promise.map(files, f => {
0
0
0
61 62 63 64 65 66 67 68 69 70
console.log(clipPath); if (!fs.existsSync(clipPath)) { //fs.mkdirSync(clipPath); return; } dir.files(clipPath, function(err, files) { if (err) throw err; clip['youtube'] = []; _.each(files, function(absPath) { var o = Object.create(null);
0
0
2
node-dir.readFiles is the most popular function in node-dir (61 examples)