UNPKG

856 BJavaScriptView Raw
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10var fs = require('fs');
11var path = require('path');
12var chalk = require('chalk');
13
14function checkRequiredFiles(files) {
15 var currentFilePath;
16 try {
17 files.forEach(filePath => {
18 currentFilePath = filePath;
19 fs.accessSync(filePath, fs.F_OK);
20 });
21 return true;
22 } catch (err) {
23 var dirName = path.dirname(currentFilePath);
24 var fileName = path.basename(currentFilePath);
25 console.log(chalk.red('Could not find a required file.'));
26 console.log(chalk.red(' Name: ') + chalk.cyan(fileName));
27 console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName));
28 return false;
29 }
30}
31
32module.exports = checkRequiredFiles;