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' ;
10
9
import { readFileSync } from 'fs' ;
11
10
import { Observable , ReplaySubject , concat , of } from 'rxjs' ;
12
11
import { concatMap , defaultIfEmpty , filter , first , map , toArray } from 'rxjs/operators' ;
13
12
import * as url from 'url' ;
14
13
import { NpmRepositoryPackageJson } from './npm-package-json' ;
15
14
16
15
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
+
21
24
function getNpmConfigOption (
22
25
option : string ,
23
26
scope ?: string ,
@@ -43,26 +46,15 @@ function getNpmConfigOption(
43
46
44
47
const subject = new ReplaySubject < string | undefined > ( 1 ) ;
45
48
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 ) {
62
51
subject . next ( ) ;
63
- subject . complete ( ) ;
52
+ } else {
53
+ subject . next ( optionValue ) ;
64
54
}
65
55
56
+ subject . complete ( ) ;
57
+
66
58
value = subject . asObservable ( ) ;
67
59
npmConfigOptionCache . set ( fullOption , value ) ;
68
60
0 commit comments