66 * found in the LICENSE file at https://angular.io/license
77 */
88import { logging } from '@angular-devkit/core' ;
9+ import { exec } from 'child_process' ;
910import { readFileSync } from 'fs' ;
1011import { Observable , ReplaySubject , concat , of } from 'rxjs' ;
1112import { concatMap , defaultIfEmpty , filter , first , map , toArray } from 'rxjs/operators' ;
1213import * as url from 'url' ;
1314import { NpmRepositoryPackageJson } from './npm-package-json' ;
1415
1516const RegistryClient = require ( 'npm-registry-client' ) ;
16- const rc = require ( 'rc' ) ;
1717
1818const npmPackageJsonCache = new Map < string , Observable < NpmRepositoryPackageJson > > ( ) ;
1919const npmConfigOptionCache = new Map < string , Observable < string | undefined > > ( ) ;
2020
21-
22- const npmConfig = rc ( 'npm' , { } , { } ) ;
23-
2421function getNpmConfigOption (
2522 option : string ,
2623 scope ?: string ,
@@ -46,15 +43,26 @@ function getNpmConfigOption(
4643
4744 const subject = new ReplaySubject < string | undefined > ( 1 ) ;
4845
49- const optionValue = npmConfig && npmConfig [ fullOption ] ;
50- if ( optionValue == undefined || optionValue == null ) {
46+ try {
47+ exec ( `npm get ${ fullOption } ` , ( error , data ) => {
48+ if ( error ) {
49+ subject . next ( ) ;
50+ } else {
51+ data = data . trim ( ) ;
52+ if ( ! data || data === 'undefined' || data === 'null' ) {
53+ subject . next ( ) ;
54+ } else {
55+ subject . next ( data ) ;
56+ }
57+ }
58+
59+ subject . complete ( ) ;
60+ } ) ;
61+ } catch {
5162 subject . next ( ) ;
52- } else {
53- subject . next ( optionValue ) ;
63+ subject . complete ( ) ;
5464 }
5565
56- subject . complete ( ) ;
57-
5866 value = subject . asObservable ( ) ;
5967 npmConfigOptionCache . set ( fullOption , value ) ;
6068
0 commit comments