@@ -33,35 +33,33 @@ export async function getVectorConfig(relativeLocation) {
3333}
3434
3535function getConfig ( configJsonFilename ) {
36- let deferred = Promise . defer ( ) ;
37-
38- request (
39- { method : "GET" , url : configJsonFilename } ,
40- ( err , response , body ) => {
41- if ( err || response . status < 200 || response . status >= 300 ) {
42- // Lack of a config isn't an error, we should
43- // just use the defaults.
44- // Also treat a blank config as no config, assuming
45- // the status code is 0, because we don't get 404s
46- // from file: URIs so this is the only way we can
47- // not fail if the file doesn't exist when loading
48- // from a file:// URI.
49- if ( response ) {
50- if ( response . status == 404 || ( response . status == 0 && body == '' ) ) {
51- deferred . resolve ( { } ) ;
36+ return new Promise ( function ( resolve , reject ) {
37+ request (
38+ { method : "GET" , url : configJsonFilename } ,
39+ ( err , response , body ) => {
40+ if ( err || response . status < 200 || response . status >= 300 ) {
41+ // Lack of a config isn't an error, we should
42+ // just use the defaults.
43+ // Also treat a blank config as no config, assuming
44+ // the status code is 0, because we don't get 404s
45+ // from file: URIs so this is the only way we can
46+ // not fail if the file doesn't exist when loading
47+ // from a file:// URI.
48+ if ( response ) {
49+ if ( response . status == 404 || ( response . status == 0 && body == '' ) ) {
50+ resolve ( { } ) ;
51+ }
5252 }
53+ reject ( { err : err , response : response } ) ;
54+ return ;
5355 }
54- deferred . reject ( { err : err , response : response } ) ;
55- return ;
56- }
5756
58- // We parse the JSON ourselves rather than use the JSON
59- // parameter, since this throws a parse error on empty
60- // which breaks if there's no config.json and we're
61- // loading from the filesystem (see above).
62- deferred . resolve ( JSON . parse ( body ) ) ;
63- }
64- ) ;
65-
66- return deferred . promise ;
57+ // We parse the JSON ourselves rather than use the JSON
58+ // parameter, since this throws a parse error on empty
59+ // which breaks if there's no config.json and we're
60+ // loading from the filesystem (see above).
61+ resolve ( JSON . parse ( body ) ) ;
62+ }
63+ ) ;
64+ } )
6765}
0 commit comments