Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
this.context.logger.info(statsErrorsToString(json, statsConfig));
}
}
obs.next({ success: true });
obs.next({ success: !stats.hasErrors() });

if (first && options.open) {
first = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Browser Builder bundle budgets', () => {
runTargetSpec(host, browserTargetSpec, overrides).pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(false)),
).subscribe(undefined, done.fail, done);
}, Timeout.Standard);
}, Timeout.Complex);

it('shows warnings', (done) => {
const overrides = {
Expand All @@ -52,5 +52,5 @@ describe('Browser Builder bundle budgets', () => {
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
tap(() => expect(logger.includes('WARNING')).toBe(true)),
).subscribe(undefined, done.fail, done);
}, Timeout.Standard);
}, Timeout.Complex);
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,5 @@ describe('Browser Builder lazy modules', () => {
.exists(join(outputPath, 'src-app-lazy-lazy-module-ngfactory.js')))
.toBe(true)),
).subscribe(undefined, done.fail, done);
}, Timeout.Basic);
}, Timeout.Complex);
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ describe('Browser Builder license extraction', () => {
expect(host.scopedSync().exists(fileName)).toBe(true);
}),
).subscribe(undefined, done.fail, done);
}, Timeout.Standard);
}, Timeout.Complex);
});
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('Browser Builder styles', () => {
runTargetSpec(host, browserTargetSpec, overrides).pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
).subscribe(undefined, done.fail, done);
}, Timeout.Basic);
}, Timeout.Complex);

extensionsWithVariableSupport.forEach(ext => {
it(`supports ${ext} includePaths`, (done) => {
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('Browser Builder styles', () => {
'/*! important-comment */div{-ms-flex:1;flex:1}');
}),
).subscribe(undefined, done.fail, done);
}, Timeout.Standard);
}, Timeout.Complex);

// TODO: consider making this a unit test in the url processing plugins.
it(`supports baseHref and deployUrl in resource urls`, (done) => {
Expand Down
14 changes: 11 additions & 3 deletions packages/angular_devkit/core/node/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import * as fs from 'fs';
import { EMPTY, Observable, concat, from as observableFrom } from 'rxjs';
import { EMPTY, Observable, concat, from as observableFrom, throwError } from 'rxjs';
import {
concatMap,
ignoreElements,
Expand Down Expand Up @@ -257,9 +257,17 @@ export class NodeJsSyncHost implements virtualFs.Host<fs.Stats> {
for (const name of fs.readdirSync(getSystemPath(path))) {
this.delete(join(path, name)).subscribe();
}
fs.rmdirSync(getSystemPath(path));
try {
fs.rmdirSync(getSystemPath(path));
} catch (error) {
return throwError(error);
}
} else {
fs.unlinkSync(getSystemPath(path));
try {
fs.unlinkSync(getSystemPath(path));
} catch (error) {
return throwError(error);
}
}

return EMPTY;
Expand Down
11 changes: 11 additions & 0 deletions packages/angular_devkit/core/src/utils/literals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ export function stripIndents(strings: TemplateStringsArray, ...values: any[]) {
.join('\n')
.trim();
}

// tslint:disable-next-line:no-any
export function trimNewlines(strings: TemplateStringsArray, ...values: any[]) {
const endResult = String.raw(strings, ...values);

return endResult
// Remove the newline at the start.
.replace(/^(?:\r?\n)+/, '')
// Remove the newline at the end and following whitespace.
.replace(/(?:\r?\n(?:\s*))$/, '');
}
12 changes: 11 additions & 1 deletion packages/angular_devkit/core/src/utils/literals_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { oneLine, stripIndent, stripIndents } from './literals';
import { oneLine, stripIndent, stripIndents, trimNewlines } from './literals';

describe('literals', () => {
describe('stripIndent', () => {
Expand Down Expand Up @@ -43,4 +43,14 @@ describe('literals', () => {
expect(test).toBe('hello world how are you? blue red test');
});
});

describe('trimNewlines', () => {
it('works', () => {
const test = trimNewlines`
hello world
`;

expect(test).toBe(' hello world');
});
});
});