@lipemat/js-boilerplate
Version:
Dependencies and scripts for a no config JavaScript app
38 lines (37 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackageConfig = getPackageConfig;
const path_1 = require("path");
const node_fs_1 = require("node:fs");
const workingDirectory = (0, node_fs_1.realpathSync)(process.cwd());
const defaults = {
brotliFiles: false,
cssTsFiles: false,
jsPath: './',
packageDirectory: workingDirectory,
shortCssClasses: false,
url: 'http://localhost',
};
let packageConfig = require((0, path_1.resolve)(workingDirectory, 'package.json'));
packageConfig = { ...defaults, ...packageConfig };
packageConfig.workingDirectory = packageConfig.jsPath !== '' ? (0, path_1.resolve)(packageConfig.jsPath) : workingDirectory;
try {
const localConfig = require((0, path_1.resolve)(workingDirectory, './local-config.json'));
packageConfig = { ...packageConfig, ...localConfig };
}
catch (e) {
}
/**
* Helper function to get the results of `packageConfig`.
*
* - Allows mocking the results of `packageConfig` for testing.
* - Allows getting the config through a callback instead of an import.
*
* @since 10.3.0
*/
function getPackageConfig() {
return packageConfig;
}
packageConfig.getPackageConfig = getPackageConfig;
packageConfig.default = packageConfig;
module.exports = packageConfig;