@villedemontreal/general-utils
Version:
General utilities library
38 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.constants = exports.Constants = void 0;
const fs = require("fs");
const path = require("path");
const app_root_path_1 = require("app-root-path");
/**
* Library constants
*/
class Constants {
constructor() {
// From the "dist/src/config" folder
this.libRoot = path.normalize(__dirname + '/../..');
this.appRoot = app_root_path_1.path;
}
// ==========================================
// Directory path for test data
// ==========================================
get testDataDirPath() {
return this.libRoot + '/test-data';
}
findModulePath(subPath) {
let current = this.libRoot;
let counter = 0;
while (counter < 10 && current !== '/' && fs.existsSync(current)) {
const p = path.join(current, subPath);
if (fs.existsSync(p)) {
return path.normalize(p);
}
current = path.normalize(path.join(current, '..'));
counter += 1;
}
throw new Error(`Could not find module "${subPath}"`);
}
}
exports.Constants = Constants;
exports.constants = new Constants();
//# sourceMappingURL=constants.js.map