This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -86,7 +86,7 @@ const resolve = (resolver, {key, filePath, rootDir, optional}) => {
filePath
)} in the ${_chalk().default.bold(key)} option was not found.
${_chalk().default.bold('<rootDir>')} is: ${rootDir}`);
}
} /// can cast as string since nulls will be thrown
return module;
};
@@ -106,31 +106,32 @@ const replaceRootDirInPath = (rootDir, filePath) => {
rootDir,
_path().default.normalize('./' + filePath.substr('<rootDir>'.length))
);
}; // TODO: Type as returning same type as input
};
exports.replaceRootDirInPath = replaceRootDirInPath;
const _replaceRootDirInObject = (rootDir, config) => {
if (config !== null) {
const newConfig = {};
const newConfig = {};
for (const configKey in config) {
newConfig[configKey] =
configKey === 'rootDir'
? config[configKey]
: _replaceRootDirTags(rootDir, config[configKey]);
}
return newConfig;
for (const configKey in config) {
newConfig[configKey] =
configKey === 'rootDir'
? config[configKey]
: _replaceRootDirTags(rootDir, config[configKey]);
}
return config;
}; // TODO: Type as returning same type as input
return newConfig;
};
const _replaceRootDirTags = (rootDir, config) => {
if (config == null) {
return config;
}
switch (typeof config) {
case 'object':
if (Array.isArray(config)) {
/// can be string[] or {}[]
return config.map(item => _replaceRootDirTags(rootDir, item));
}