Skip to content

Commit

Permalink
chore(js): pass full context to parseTargetString (#19136)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Sep 20, 2023
1 parent a020f1d commit 3069f3e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
9 changes: 3 additions & 6 deletions packages/js/src/executors/node/node.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export async function* nodeExecutor(
) {
process.env.NODE_ENV ??= context?.configurationName ?? 'development';
const project = context.projectGraph.nodes[context.projectName];
const buildTarget = parseTargetString(
options.buildTarget,
context.projectGraph
);
const buildTarget = parseTargetString(options.buildTarget, context);

if (!project.data.targets[buildTarget.target]) {
throw new Error(
Expand Down Expand Up @@ -313,7 +310,7 @@ function calculateResolveMappings(
context: ExecutorContext,
options: NodeExecutorOptions
) {
const parsed = parseTargetString(options.buildTarget, context.projectGraph);
const parsed = parseTargetString(options.buildTarget, context);
const { dependencies } = calculateProjectBuildableDependencies(
context.taskGraph,
context.projectGraph,
Expand All @@ -336,7 +333,7 @@ function runWaitUntilTargets(
): Promise<{ success: boolean }[]> {
return Promise.all(
options.waitUntilTargets.map(async (waitUntilTarget) => {
const target = parseTargetString(waitUntilTarget, context.projectGraph);
const target = parseTargetString(waitUntilTarget, context);
const output = await runExecutor(target, {}, context);
return new Promise<{ success: boolean }>(async (resolve) => {
let event = await output.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function createTaskInfo(
context: ExecutorContext,
tsConfig: TypescriptInMemoryTsConfig
): TaskInfo {
const target = parseTargetString(taskName, context.projectGraph);
const target = parseTargetString(taskName, context);

const taskContext = {
...context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function normalizeTasksOptions(
context: ExecutorContext
): Record<string, NormalizedExecutorOptions> {
return Object.entries(inputs).reduce((tasksOptions, [taskName, options]) => {
const { project } = parseTargetString(taskName, context.projectGraph);
const { project } = parseTargetString(taskName, context);
const { sourceRoot, root } =
context.projectsConfigurations.projects[project];
tasksOptions[taskName] = normalizeOptions(
Expand Down
17 changes: 5 additions & 12 deletions packages/js/src/executors/tsc/lib/get-tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function generateTaskProjectTsConfig(
context: ExecutorContext,
taskInMemoryTsConfigMap: Record<string, TypescriptInMemoryTsConfig>
): string {
const { project } = parseTargetString(task, context.projectGraph);
const { project } = parseTargetString(task, context);
if (projectTsConfigCache.has(project)) {
const { tsConfig, tsConfigPath } = projectTsConfigCache.get(project);
taskInMemoryTsConfigMap[task] = tsConfig;
Expand Down Expand Up @@ -104,25 +104,18 @@ function getDependencyTasksInOtherProjects(
context: ExecutorContext
): string[] {
return context.taskGraph.dependencies[task].filter(
(t) =>
t !== task &&
parseTargetString(t, context.projectGraph).project !== project
(t) => t !== task && parseTargetString(t, context).project !== project
);
}

function getDependencyTasksInSameProject(
task: string,
context: ExecutorContext
): string[] {
const { project: taskProject } = parseTargetString(
task,
context.projectGraph
);
const { project: taskProject } = parseTargetString(task, context);

return Object.keys(context.taskGraph.tasks).filter(
(t) =>
t !== task &&
parseTargetString(t, context.projectGraph).project === taskProject
(t) => t !== task && parseTargetString(t, context).project === taskProject
);
}

Expand Down Expand Up @@ -167,7 +160,7 @@ function getInMemoryTsConfig(
}

function hasTscExecutor(task: string, context: ExecutorContext): boolean {
const { project, target } = parseTargetString(task, context.projectGraph);
const { project, target } = parseTargetString(task, context);

return (
context.projectGraph.nodes[project].data.targets[target].executor ===
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/executors/tsc/tsc.batch-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function createTypescriptCompilationContext(
Object.entries(taskInMemoryTsConfigMap).forEach(([task, tsConfig]) => {
if (!tsCompilationContext[tsConfig.path]) {
tsCompilationContext[tsConfig.path] = {
project: parseTargetString(task, context.projectGraph).project,
project: parseTargetString(task, context).project,
transformers: [],
tsConfig: tsConfig,
};
Expand Down

0 comments on commit 3069f3e

Please sign in to comment.