66 * found in the LICENSE file at https://angular.io/license
77 */
88import { logging } from '@angular-devkit/core' ;
9- import { exec } from 'child_process' ;
109import { readFileSync } from 'fs' ;
1110import { Observable , ReplaySubject , concat , of } from 'rxjs' ;
1211import { concatMap , defaultIfEmpty , filter , first , map , toArray } from 'rxjs/operators' ;
1312import * as url from 'url' ;
1413import { NpmRepositoryPackageJson } from './npm-package-json' ;
1514
1615const 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+
2124function getNpmConfigOption (
2225 option : string ,
2326 scope ?: string ,
@@ -43,26 +46,15 @@ function getNpmConfigOption(
4346
4447 const subject = new ReplaySubject < string | undefined > ( 1 ) ;
4548
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 {
49+ const optionValue = npmConfig && npmConfig [ fullOption ] ;
50+ if ( optionValue == undefined || optionValue == null ) {
6251 subject . next ( ) ;
63- subject . complete ( ) ;
52+ } else {
53+ subject . next ( optionValue ) ;
6454 }
6555
56+ subject . complete ( ) ;
57+
6658 value = subject . asObservable ( ) ;
6759 npmConfigOptionCache . set ( fullOption , value ) ;
6860
0 commit comments