Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function analyzeKarmaConfig(content: string): KarmaConfigAnalysis {
case ts.SyntaxKind.ArrayLiteralExpression:
return (node as ts.ArrayLiteralExpression).elements.map(extractValue);
case ts.SyntaxKind.ObjectLiteralExpression: {
const obj: { [key: string]: KarmaConfigValue } = {};
const obj: { [key: string]: KarmaConfigValue } = Object.create(null);
for (const prop of (node as ts.ObjectLiteralExpression).properties) {
if (isSupportedPropertyAssignment(prop)) {
// Recursively extract values for nested objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ export async function generateDefaultKarmaConfig(

// TODO: Replace this with the actual schematic templating logic.
template = template
.replace(
/<%= relativePathToWorkspaceRoot %>/g,
.replace(/<%= relativePathToWorkspaceRoot %>/g, () =>
path.normalize(relativePathToWorkspaceRoot).replace(/\\/g, '/'),
)
.replace(/<%= folderName %>/g, projectName);
.replace(/<%= folderName %>/g, () => projectName);

const devkitPluginRegex = /<% if \(needDevkitPlugin\) { %>(.*?)<% } %>/gs;
const replacement = needDevkitPlugin ? '$1' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ async function processTestTargetOptions(
let needsIstanbul = false;
for (const [configName, options] of allTargetOptions(testTarget, false)) {
const configKey = configName || '';
if (configKey === '__proto__' || configKey === 'constructor') {
continue;
}
if (!customBuildOptions[configKey]) {
// Match Karma behavior where AOT was disabled by default
customBuildOptions[configKey] = {
Expand Down Expand Up @@ -276,7 +279,10 @@ function updateProjects(tree: Tree, context: SchematicContext): Rule {
tsConfigsToUpdate.add(join(project.root, 'tsconfig.spec.json'));

// Store custom build options to move to a new build configuration if needed
const customBuildOptions: Record<string, Record<string, json.JsonValue | undefined>> = {};
const customBuildOptions: Record<
string,
Record<string, json.JsonValue | undefined>
> = Object.create(null);
Comment thread
clydin marked this conversation as resolved.

const projectCoverageInfo = await processTestTargetOptions(
testTarget,
Expand All @@ -300,6 +306,9 @@ function updateProjects(tree: Tree, context: SchematicContext): Rule {
const baseOptions = buildTarget.options || {};

for (const [configKey, configOptions] of Object.entries(customBuildOptions)) {
if (configKey === '__proto__' || configKey === 'constructor') {
continue;
}
const finalConfig: Record<string, json.JsonValue | undefined> = {};

// Omit options that already have the same value in the base build options.
Expand Down
Loading