Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Feb 7, 2025
1 parent a51df17 commit 79a7f08
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
ci_tests:
uses: dsi-hug/actions/.github/workflows/action.yml@v3
with:
runs-on: '["windows-latest"]'
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]'
node-versions: '[22]'
working-directory: projects/lib
lint: true
Expand Down
8 changes: 0 additions & 8 deletions projects/lib/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ import { get } from 'https';
*/
export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 300): Promise<Buffer> =>
new Promise((resolve, reject) => {
try {
if (typeof url === 'string') {
new URL(url);
}
} catch (err: unknown) {
console.error('@@@@@@@@@@@@', url, err);
}

const { hostname, pathname } = (typeof url === 'string') ? new URL(url) : url;
// eslint-disable-next-line consistent-return
const req = get({ hostname, path: pathname }, (res: IncomingMessage) => {
Expand Down
8 changes: 4 additions & 4 deletions projects/lib/src/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { JsonObject } from '@angular-devkit/core';
import { CoreSchemaRegistry } from '@angular-devkit/core/src/json/schema/index';
import { SchematicContext } from '@angular-devkit/schematics';
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
import { dirname as pathDirname, join as pathJoin } from 'path';
import { dirname as pathDirname, posix } from 'path';

import { getJsonFromUrl } from './request';

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

const pkgJson = await getJsonFromUrl(pathJoin(url, 'package.json'), retries, backoff);
const pkgJson = await getJsonFromUrl(posix.join(url, 'package.json'), retries, backoff);
if (pkgJson?.['schematics']) {
const collectionJson = await getJsonFromUrl(pathJoin(url, pkgJson['schematics'] as string), retries, backoff);
const collectionJson = await getJsonFromUrl(posix.join(url, pkgJson['schematics'] as string), retries, backoff);
if (collectionJson?.['schematics']) {
const schema = ((collectionJson['schematics'] as JsonObject)[schematicName] as JsonObject)?.['schema'] as string;
if (!schema) {
throw new Error(`Schematic "${schematicName}" not found in collection "${packageName}".`);
}
return await getJsonFromUrl(pathJoin(url, pathDirname(pkgJson['schematics'] as string), schema), retries, backoff);
return await getJsonFromUrl(posix.join(url, pathDirname(pkgJson['schematics'] as string), schema), retries, backoff);
}
}

Expand Down

0 comments on commit 79a7f08

Please sign in to comment.