@@ -9,17 +9,23 @@ exports.desc = "Get a public URL for your API";
9
9
exports . category = "services" ;
10
10
11
11
exports . run = function ( config , info , cb ) {
12
- if ( ! cb ) cb = ( ) => { } ;
12
+ if ( ! cb ) cb = ( err ) => {
13
+ if ( err ) {
14
+ console . error ( err )
15
+ return process . exit ( 1 ) ;
16
+ }
17
+
18
+ process . exit ( ) ;
19
+ } ;
13
20
14
21
const [ apiKey , id ] = info . opts . token . split ( '-' ) ;
15
22
16
23
function callback ( err , response , data ) {
17
24
if ( err ) return cb ( err ) ;
18
- if ( response . statusCode === 201 ) {
19
- console . log ( "" ) ;
25
+ if ( response . statusCode === 201 || response . statusCode === 200 ) {
26
+ console . log ( data ) ;
20
27
console . log ( "Success! " . green ) ;
21
28
} else {
22
- console . log ( data )
23
29
console . error ( "There was an error uploading!" . red ) ;
24
30
}
25
31
@@ -29,14 +35,14 @@ exports.run = function(config, info, cb) {
29
35
30
36
const options = {
31
37
formData : {
32
- swagger : fs . createReadStream ( path . join ( process . cwd ( ) , info . args [ 0 ] ) ) ,
38
+ swagger : fs . createReadStream ( path . resolve ( process . cwd ( ) , info . args [ 0 ] ) ) ,
33
39
} ,
34
40
auth : { user : apiKey } ,
35
41
} ;
36
42
37
43
if ( ! id ) {
38
- request . post ( `${ config . host . url } /v1/ api/swagger` , options , callback ) ;
44
+ request . post ( `${ config . host . url } /api/v1 /swagger` , options , callback ) ;
39
45
} else {
40
- request . put ( `${ config . host . url } /v1/ api/swagger/${ id } ` , options , callback ) ;
46
+ request . put ( `${ config . host . url } /api/v1 /swagger/${ id } ` , options , callback ) ;
41
47
}
42
48
} ;
0 commit comments