Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 8da62b8

Browse files
Make AngularCliBuilder provide better information about timeouts
1 parent 39e6121 commit 8da62b8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Microsoft.AspNetCore.SpaServices.Extensions/AngularCli/AngularCliBuilder.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public AngularCliBuilder(string npmScript)
3939
}
4040

4141
/// <inheritdoc />
42-
public Task Build(ISpaBuilder spaBuilder)
42+
public async Task Build(ISpaBuilder spaBuilder)
4343
{
4444
var sourcePath = spaBuilder.Options.SourcePath;
4545
if (string.IsNullOrEmpty(sourcePath))
@@ -57,18 +57,27 @@ public Task Build(ISpaBuilder spaBuilder)
5757
null);
5858
npmScriptRunner.AttachToLogger(logger);
5959

60+
using (var stdOutReader = new EventedStreamStringReader(npmScriptRunner.StdOut))
6061
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
6162
{
6263
try
6364
{
64-
return npmScriptRunner.StdOut.WaitForMatch(
65-
new Regex("chunk", RegexOptions.None, RegexMatchTimeout),
65+
await npmScriptRunner.StdOut.WaitForMatch(
66+
new Regex("Date", RegexOptions.None, RegexMatchTimeout),
6667
BuildTimeout);
6768
}
6869
catch (EndOfStreamException ex)
6970
{
7071
throw new InvalidOperationException(
71-
$"The NPM script '{_npmScriptName}' exited without indicating success. " +
72+
$"The NPM script '{_npmScriptName}' exited without indicating success.\n" +
73+
$"Output was: {stdOutReader.ReadAsString()}\n" +
74+
$"Error output was: {stdErrReader.ReadAsString()}", ex);
75+
}
76+
catch (OperationCanceledException ex)
77+
{
78+
throw new InvalidOperationException(
79+
$"The NPM script '{_npmScriptName}' timed out without indicating success. " +
80+
$"Output was: {stdOutReader.ReadAsString()}\n" +
7281
$"Error output was: {stdErrReader.ReadAsString()}", ex);
7382
}
7483
}

0 commit comments

Comments
 (0)