Skip to content
Snippets Groups Projects
Commit 79cee4a7 authored by OZGCloud's avatar OZGCloud
Browse files

change countFiles method to also use fs-Extra

parent ddca9840
Branches
Tags
No related merge requests found
import { Db, Long, MongoClient, ObjectId } from 'mongodb'; import { Db, Long, MongoClient, ObjectId } from 'mongodb';
const fs = require('fs');
const fsExtra = require('fs-extra'); const fsExtra = require('fs-extra');
const Binary = require('mongodb').Binary; const Binary = require('mongodb').Binary;
...@@ -317,15 +316,12 @@ function dropCollections(databaseUrl, databaseName, collections) { ...@@ -317,15 +316,12 @@ function dropCollections(databaseUrl, databaseName, collections) {
}); });
} }
function countFiles(folderName: string): Promise<number> { function countFiles(folderName) {
return new Promise((resolve, reject) => { return fsExtra
fs.readdir(folderName, (err, files) => { .readdir(folderName)
if (err) { .then((files) => files.length)
console.error(err); .catch((err) => {
return reject(err); throw new Error(`Counting files failed: ${err.message}`);
}
resolve(files.length);
});
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment