mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-24 08:46:20 -04:00
initial commit
This commit is contained in:
commit
f5b2b47136
46 changed files with 2350 additions and 0 deletions
34
tasks/ensure-files.js
Normal file
34
tasks/ensure-files.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
* @param {Array<string>} files
|
||||
* @param {Function} cb
|
||||
*/
|
||||
|
||||
function ensureFiles(files, cb) {
|
||||
var missingFiles = files.reduce(function(prev, filePath) {
|
||||
var fileFound = false;
|
||||
|
||||
try {
|
||||
fileFound = fs.statSync(filePath).isFile();
|
||||
} catch (e) { }
|
||||
|
||||
if (!fileFound) {
|
||||
prev.push(filePath + ' Not Found');
|
||||
}
|
||||
|
||||
return prev;
|
||||
}, []);
|
||||
|
||||
if (missingFiles.length) {
|
||||
var err = new Error('Missing Required Files\n' + missingFiles.join('\n'));
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb(err);
|
||||
} else if (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ensureFiles;
|
Loading…
Add table
Add a link
Reference in a new issue