6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { logging } from '@angular-devkit/core' ;
9
+ import { exec } from 'child_process' ;
9
10
import { readFileSync } from 'fs' ;
10
11
import { Observable , ReplaySubject , concat , of } from 'rxjs' ;
11
12
import { concatMap , defaultIfEmpty , filter , first , map , toArray } from 'rxjs/operators' ;
12
13
import * as url from 'url' ;
13
14
import { NpmRepositoryPackageJson } from './npm-package-json' ;
14
15
15
16
const RegistryClient = require ( 'npm-registry-client' ) ;
16
- const rc = require ( 'rc' ) ;
17
17
18
18
const npmPackageJsonCache = new Map < string , Observable < NpmRepositoryPackageJson > > ( ) ;
19
19
const npmConfigOptionCache = new Map < string , Observable < string | undefined > > ( ) ;
20
20
21
-
22
- const npmConfig = rc ( 'npm' , { } , { } ) ;
23
-
24
21
function getNpmConfigOption (
25
22
option : string ,
26
23
scope ?: string ,
@@ -46,15 +43,26 @@ function getNpmConfigOption(
46
43
47
44
const subject = new ReplaySubject < string | undefined > ( 1 ) ;
48
45
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 {
51
62
subject . next ( ) ;
52
- } else {
53
- subject . next ( optionValue ) ;
63
+ subject . complete ( ) ;
54
64
}
55
65
56
- subject . complete ( ) ;
57
-
58
66
value = subject . asObservable ( ) ;
59
67
npmConfigOptionCache . set ( fullOption , value ) ;
60
68
0 commit comments