Skip to content

Commit 2729ee9

Browse files
committed
fix: tests
1 parent 8ad6bda commit 2729ee9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

projects/lib/specs/schematics.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ describe('schematics', () => {
5252

5353
it('helper: getSchematicSchemaOptions - non existing package external', async () => {
5454
const test$ = getSchematicSchemaOptions(context, 'sentry', '@hug/non-existing-package', true, 0);
55-
await expectAsync(test$).toBeRejectedWithError('Request error (404): https://cdn.jsdelivr.net//npm/@hug/non-existing-package@latest/package.json');
55+
await expectAsync(test$).toBeRejectedWithError('Request error (404): https://cdn.jsdelivr.net/npm/@hug/non-existing-package@latest/package.json');
5656
});
5757
});

projects/lib/src/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3
3131
} else {
3232
res.removeAllListeners();
3333
res.resume(); // consume response data to free up memory
34-
reject(new Error(`Request error (${String(res.statusCode)}): https://${hostname}/${pathname}`));
34+
reject(new Error(`Request error (${String(res.statusCode)}): https://${hostname}${pathname}`));
3535
}
3636
});
3737
const abort = (error: Error | string): void => {

projects/lib/src/schematics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { JsonObject } from '@angular-devkit/core';
33
import { CoreSchemaRegistry } from '@angular-devkit/core/src/json/schema/index';
44
import { SchematicContext } from '@angular-devkit/schematics';
55
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
6-
import { dirname as pathDirname, join as pathJoin } from 'path';
6+
import { dirname as pathDirname, posix } from 'path';
77

88
import { getJsonFromUrl } from './request';
99

@@ -14,15 +14,15 @@ export interface NgCliOption extends Option {
1414
const getExternalSchemaJson = async (packageName: string, schematicName = 'ng-add', retries = 3, backoff = 300): Promise<JsonObject> => {
1515
const url = `http://cdn.jsdelivr.net/npm/${packageName}@latest`;
1616

17-
const pkgJson = await getJsonFromUrl(pathJoin(url, 'package.json'), retries, backoff);
17+
const pkgJson = await getJsonFromUrl(posix.join(url, 'package.json'), retries, backoff);
1818
if (pkgJson?.['schematics']) {
19-
const collectionJson = await getJsonFromUrl(pathJoin(url, pkgJson['schematics'] as string), retries, backoff);
19+
const collectionJson = await getJsonFromUrl(posix.join(url, pkgJson['schematics'] as string), retries, backoff);
2020
if (collectionJson?.['schematics']) {
2121
const schema = ((collectionJson['schematics'] as JsonObject)[schematicName] as JsonObject)?.['schema'] as string;
2222
if (!schema) {
2323
throw new Error(`Schematic "${schematicName}" not found in collection "${packageName}".`);
2424
}
25-
return await getJsonFromUrl(pathJoin(url, pathDirname(pkgJson['schematics'] as string), schema), retries, backoff);
25+
return await getJsonFromUrl(posix.join(url, pathDirname(pkgJson['schematics'] as string), schema), retries, backoff);
2626
}
2727
}
2828

0 commit comments

Comments
 (0)