Skip to content

Commit

Permalink
refactor(@angular/cli): convert pacote usage from require to import
Browse files Browse the repository at this point in the history
The removal of require usage supports the eventual shift to an ESM output for the CLI package.
  • Loading branch information
clydin authored and filipesilva committed Aug 25, 2021
1 parent 266233c commit c7e3923
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions packages/angular/cli/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ declare module 'npm-pick-manifest' {
): import('../utilities/package-metadata').PackageManifest;
export = pickManifest;
}

declare module 'pacote' {
export function manifest(
specifier: string,
options: Record<string, unknown>,
): Promise<{ name: string; version: string }>;

export function packument(
specifier: string,
options: Record<string, unknown>,
): Promise<import('../utilities/package-metadata').NpmRepositoryPackageJson>;
}
3 changes: 1 addition & 2 deletions packages/angular/cli/utilities/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import * as lockfile from '@yarnpkg/lockfile';
import { existsSync, readFileSync } from 'fs';
import * as ini from 'ini';
import { homedir } from 'os';
import * as pacote from 'pacote';
import * as path from 'path';
import { JsonSchemaForNpmPackageJsonFiles } from './package-json';

const pacote = require('pacote');

const npmPackageJsonCache = new Map<string, Promise<Partial<NpmRepositoryPackageJson>>>();

export interface NpmRepositoryPackageJson {
Expand Down

0 comments on commit c7e3923

Please sign in to comment.