Skip to content
Merged
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
38 changes: 36 additions & 2 deletions src/deploy/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
BuilderContext,
BuilderRun,
ScheduleOptions,
Target
Target,
BuilderOutput
} from '@angular-devkit/architect/src/index';

import deploy from './actions';
Expand Down Expand Up @@ -145,6 +146,25 @@ describe('Deploy Angular apps', () => {
);
}
});

it('throws if app building fails', async () => {
context.scheduleTarget = (
_: Target,
__?: JsonObject,
___?: ScheduleOptions
) =>
Promise.resolve({
result: Promise.resolve(
createBuilderOutputMock(false, 'build error test')
)
} as BuilderRun);
try {
await deploy(mockEngine, context, getBuildTarget(), {});
fail();
} catch (e) {
expect(e.message).toMatch(/build error test/);
}
});
});
});

Expand All @@ -163,7 +183,9 @@ const initMocks = () => {
workspaceRoot: 'my/workspace/root',
logger: new logging.NullLogger() as any,
scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) =>
Promise.resolve({} as BuilderRun),
Promise.resolve({
result: Promise.resolve(createBuilderOutputMock(true, ''))
} as BuilderRun),
getTargetOptions: (t: Target) =>
Promise.resolve({
project: `projects/${t.project}/some-file.json`,
Expand All @@ -173,6 +195,18 @@ const initMocks = () => {
} as unknown) as BuilderContext;
};

const createBuilderOutputMock = (
success: boolean,
error: string
): BuilderOutput => {
return {
info: { info: null },
error: error,
success: success,
target: {} as Target
};
};

const getBuildTarget = (): BuildTarget => ({
name: `${PROJECT}:build:production`
});
6 changes: 5 additions & 1 deletion src/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export default async function deploy(
}

const build = await context.scheduleTarget(target);
await build.result;
const buildResult = await build.result;

if (!buildResult.success) {
throw new Error(buildResult.error);
}
}

const targetFromStr = targetFromTargetString(buildTarget.name);
Expand Down