@blitzjs/config
Advanced tools
Comparing version 0.14.0 to 0.14.1
@@ -11,20 +11,2 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -78,25 +60,31 @@ if (!o) return; | ||
var getConfig = function getConfig(reload) { | ||
try { | ||
if (Object.keys(global.blitzConfig).length > 0 && !reload) { | ||
return Promise.resolve(global.blitzConfig); | ||
} | ||
if (global.blitzConfig && Object.keys(global.blitzConfig).length > 0 && !reload) { | ||
return global.blitzConfig; | ||
} | ||
var blitzConfig = {}; | ||
return Promise.resolve(pkgDir()).then(function (projectRoot) { | ||
for (var _iterator = _createForOfIteratorHelperLoose(configFiles), _step; !(_step = _iterator()).done;) { | ||
var configFile = _step.value; | ||
var blitzConfig = {}; | ||
var projectRoot = pkgDir.sync() || process.cwd(); | ||
if (fs.existsSync(path.join(projectRoot, configFile))) { | ||
var file = require(path.join(projectRoot, configFile)); | ||
for (var _iterator = _createForOfIteratorHelperLoose(configFiles), _step; !(_step = _iterator()).done;) { | ||
var configFile = _step.value; | ||
blitzConfig = _extends({}, blitzConfig, file); | ||
} | ||
if (fs.existsSync(path.join(projectRoot, configFile))) { | ||
var path$1 = path.join(projectRoot, configFile); | ||
var file = require(path$1); | ||
var contents = void 0; | ||
if (typeof file === 'function') { | ||
contents = file(); | ||
} else { | ||
contents = file; | ||
} | ||
global.blitzConfig = blitzConfig; | ||
return blitzConfig; | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
blitzConfig = contents; | ||
} | ||
} | ||
global.blitzConfig = blitzConfig; | ||
return blitzConfig; | ||
}; | ||
@@ -103,0 +91,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r,e=(r=require("pkg-dir"))&&"object"==typeof r&&"default"in r?r.default:r,t=require("path"),n=require("fs");function o(){return(o=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}function i(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}var a=["next.config.js"];exports.getConfig=function(r){try{if(Object.keys(global.blitzConfig).length>0&&!r)return Promise.resolve(global.blitzConfig);var l={};return Promise.resolve(e()).then((function(r){for(var e,u=function(r,e){var t;if("undefined"==typeof Symbol||null==r[Symbol.iterator]){if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return i(r,void 0);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(r,void 0):void 0}}(r))){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=r[Symbol.iterator]()).next.bind(t)}(a);!(e=u()).done;){var f=e.value;if(n.existsSync(t.join(r,f))){var c=require(t.join(r,f));l=o({},l,c)}}return global.blitzConfig=l,l}))}catch(r){return Promise.reject(r)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=(e=require("pkg-dir"))&&"object"==typeof e&&"default"in e?e.default:e,t=require("path"),n=require("fs");function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var i=["next.config.js"];exports.getConfig=function(e){if(global.blitzConfig&&Object.keys(global.blitzConfig).length>0&&!e)return global.blitzConfig;for(var a,l={},u=r.sync()||process.cwd(),f=function(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return o(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(i);!(a=f()).done;){var c=a.value;if(n.existsSync(t.join(u,c))){var s=t.join(u,c),b=require(s);l="function"==typeof b?b():b}}return global.blitzConfig=l,l}; | ||
//# sourceMappingURL=config.cjs.production.min.js.map |
@@ -5,20 +5,2 @@ import pkgDir from 'pkg-dir'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -72,25 +54,31 @@ if (!o) return; | ||
var getConfig = function getConfig(reload) { | ||
try { | ||
if (Object.keys(global.blitzConfig).length > 0 && !reload) { | ||
return Promise.resolve(global.blitzConfig); | ||
} | ||
if (global.blitzConfig && Object.keys(global.blitzConfig).length > 0 && !reload) { | ||
return global.blitzConfig; | ||
} | ||
var blitzConfig = {}; | ||
return Promise.resolve(pkgDir()).then(function (projectRoot) { | ||
for (var _iterator = _createForOfIteratorHelperLoose(configFiles), _step; !(_step = _iterator()).done;) { | ||
var configFile = _step.value; | ||
var blitzConfig = {}; | ||
var projectRoot = pkgDir.sync() || process.cwd(); | ||
if (existsSync(join(projectRoot, configFile))) { | ||
var file = require(join(projectRoot, configFile)); | ||
for (var _iterator = _createForOfIteratorHelperLoose(configFiles), _step; !(_step = _iterator()).done;) { | ||
var configFile = _step.value; | ||
blitzConfig = _extends({}, blitzConfig, file); | ||
} | ||
if (existsSync(join(projectRoot, configFile))) { | ||
var path = join(projectRoot, configFile); | ||
var file = require(path); | ||
var contents = void 0; | ||
if (typeof file === 'function') { | ||
contents = file(); | ||
} else { | ||
contents = file; | ||
} | ||
global.blitzConfig = blitzConfig; | ||
return blitzConfig; | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
blitzConfig = contents; | ||
} | ||
} | ||
global.blitzConfig = blitzConfig; | ||
return blitzConfig; | ||
}; | ||
@@ -97,0 +85,0 @@ |
/** | ||
* @param {boolean | undefined} reload - reimport config files to reset global cache | ||
*/ | ||
export declare const getConfig: (reload?: boolean | undefined) => Promise<Record<string, unknown>>; | ||
export declare const getConfig: (reload?: boolean | undefined) => Record<string, unknown>; |
@@ -10,3 +10,3 @@ { | ||
"author": "Fran Zekan <zekan.fran369@gmail.com>", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"license": "MIT", | ||
@@ -35,3 +35,3 @@ "scripts": { | ||
}, | ||
"gitHead": "9eb85f61ed1c50db48dad7f78ef5cdf1be916318" | ||
"gitHead": "278fa74e1b36ef142b312544285b791523dff005" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
14568
151