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
27 changes: 25 additions & 2 deletions src/deploy/actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonObject, logging } from '@angular-devkit/core';
import { BuilderContext, BuilderRun, ScheduleOptions, Target } from '@angular-devkit/architect/src/index';
import { BuilderContext, BuilderOutput, BuilderRun, ScheduleOptions, Target } from '@angular-devkit/architect/src/index';
import deploy from './actions';

let context: BuilderContext;
Expand Down Expand Up @@ -53,6 +53,18 @@ describe('Deploy Angular apps', () => {
expect(e.message).toMatch(/Cannot execute the build target/);
}
});

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, 'host', {});
fail();
} catch (e) {
expect(e.message).toMatch(/build error test/);
}
});
});
});

Expand Down Expand Up @@ -81,6 +93,17 @@ const initMocks = () => {
reportStatus: (_: string) => { },
reportRunning: () => { },
scheduleBuilder: (_: string, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun),
scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun)
scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({
result: Promise.resolve(createBuilderOutputMock(true, '')),
} as BuilderRun)
};
};

const createBuilderOutputMock = (success: boolean, error: string): BuilderOutput => {
return {
info: { 'info': null },
error: error,
success: success,
target: {} as Target,
};
};
6 changes: 5 additions & 1 deletion src/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default async function deploy(
project: context.target.project,
configuration
}, overrides as json.JsonObject);
await build.result;
const buildResult = await build.result;

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

await engine.run(
Expand Down