Skip to content

Commit

Permalink
clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel committed Jun 7, 2020
1 parent 656b9a7 commit b145d1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/@aws-cdk/core/lib/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ export function addDependency<T extends Element>(source: T, target: T, reason?:
}

const sourceStack = Stack.of(source);
const sourceAssembly = Stage.of(sourceStack);
const targetStack = Stack.of(target);
const targetAssembly = Stage.of(targetStack);

if (sourceAssembly !== targetAssembly) {
throw new Error(`You cannot add a dependency from '${source.node.path}' (in ${describeAssembly(sourceAssembly)}) to '${target.node.path}' (in ${describeAssembly(targetAssembly)}): dependency cannot cross stage boundaries`);
const sourceStage = Stage.of(sourceStack);
const targetStage = Stage.of(targetStack);
if (sourceStage !== targetStage) {
throw new Error(`You cannot add a dependency from '${source.node.path}' (in ${describeStage(sourceStage)}) to '${target.node.path}' (in ${describeStage(targetStage)}): dependency cannot cross stage boundaries`);
}

// find the deepest common stack between the two elements
const sourcePath = pathToRoot(sourceStack);
const targetPath = pathToRoot(targetStack);
const commonStack = findLastCommonElement(sourcePath, targetPath);

// if there is no common stack, then define an assembly-level dependency
// if there is no common stack, then define a assembly-level dependency
// between the two top-level stacks
if (!commonStack) {
const topLevelSource = sourcePath[0]; // first path element is the top-level stack
Expand Down Expand Up @@ -99,7 +99,7 @@ export function addDependency<T extends Element>(source: T, target: T, reason?:
/**
* Return a string representation of the given assembler, for use in error messages
*/
function describeAssembly(assembly: Stage | undefined): string {
function describeStage(assembly: Stage | undefined): string {
if (!assembly) { return 'an unrooted construct tree'; }
if (!assembly.parentStage) { return 'the App'; }
return `Stage '${assembly.node.path}'`;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/private/prepare-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { resolveReferences } from './refs';
*/
export function prepareApp(root: IConstruct) {
if (root.node.scope && !Stage.isStage(root)) {
throw new Error('prepareApp can only be called on an Assembly or a root construct');
throw new Error('prepareApp can only be called on a stage or a root construct');
}

// apply dependencies between resources in depending subtrees
Expand Down Expand Up @@ -67,7 +67,7 @@ function findAllNestedStacks(root: IConstruct) {
if (!Stack.isStack(stack)) { return false; }
if (!stack.nested) { return false; }

// test: if we are not within an assembly, then include it.
// test: if we are not within a stage, then include it.
if (!Stage.of(stack)) { return true; }

return Stage.of(stack) === root;
Expand Down

0 comments on commit b145d1f

Please sign in to comment.