This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community. Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it. https://www.freifunk-altdorf.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.0 KiB

'use strict';
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const EXTRACT_MODULE_NAME_REGEX = /'\.\/(.+)'/;
let didError = false;
// Make sure we have a lib to read files from. Take it as the first argument.
assert(
process.argv.length >= 3,
'Expected to receive an argument to a lib directory'
);
const pathToLib = path.resolve(process.cwd(), process.argv[2]);
fs.readdir(pathToLib, (err, files) => {
files = files.filter((filename) => path.parse(filename).ext === '.js');
files.forEach((filename) => {
const requirePath = path.join(pathToLib, filename);
const moduleName = path.parse(filename).name;
try {
require(requirePath);
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
const missingModule = e.toString().match(EXTRACT_MODULE_NAME_REGEX)[1];
console.error(moduleName, 'is missing a dependency:', missingModule);
} else {
console.error('UNKNOWN ERROR', e);
}
didError = true;
}
});
process.exit(didError ? 1 : 0);
});