@@ -52,23 +52,31 @@ var s3UrlRe = /^[sS]3:\/\/(.*?)\/(.*)/;
52
52
barfOnUnexpectedArgs ( ) ;
53
53
54
54
var client ;
55
- fs . readFile ( args . config , { encoding : 'utf8' } , function ( err , contents ) {
56
- if ( err ) {
57
- console . error ( "This utility needs a config file formatted the same as for s3cmd" ) ;
58
- process . exit ( 1 ) ;
59
- return ;
60
- }
61
- var config = ini . parse ( contents ) ;
62
- var accessKeyId , secretAccessKey ;
63
- if ( config && config . default ) {
64
- accessKeyId = config . default . access_key ;
65
- secretAccessKey = config . default . secret_key ;
66
- }
67
- if ( ! secretAccessKey || ! accessKeyId ) {
68
- console . error ( "Config file missing access_key or secret_key" ) ;
69
- process . exit ( 1 ) ;
70
- return ;
71
- }
55
+ if ( process . env . AWS_SECRET_KEY && process . env . AWS_ACCESS_KEY ) {
56
+ setup ( process . env . AWS_SECRET_KEY , process . env . AWS_ACCESS_KEY ) ;
57
+ } else {
58
+ fs . readFile ( args . config , { encoding : 'utf8' } , function ( err , contents ) {
59
+ if ( err ) {
60
+ console . error ( "This utility needs a config file formatted the same as for s3cmd" ) ;
61
+ process . exit ( 1 ) ;
62
+ return ;
63
+ }
64
+ var config = ini . parse ( contents ) ;
65
+ var accessKeyId , secretAccessKey ;
66
+ if ( config && config . default ) {
67
+ accessKeyId = config . default . access_key ;
68
+ secretAccessKey = config . default . secret_key ;
69
+ }
70
+ if ( ! secretAccessKey || ! accessKeyId ) {
71
+ console . error ( "Config file missing access_key or secret_key" ) ;
72
+ process . exit ( 1 ) ;
73
+ return ;
74
+ }
75
+ setup ( secretAccessKey , accessKeyId ) ;
76
+ } ) ;
77
+ }
78
+
79
+ function setup ( secretAccessKey , accessKeyId ) {
72
80
var maxSockets = parseInt ( args [ 'max-sockets' ] , 10 ) ;
73
81
http . globalAgent . maxSockets = maxSockets ;
74
82
https . globalAgent . maxSockets = maxSockets ;
@@ -84,7 +92,7 @@ fs.readFile(args.config, {encoding: 'utf8'}, function(err, contents) {
84
92
var fn = fns [ cmd ] ;
85
93
if ( ! fn ) fn = cmdHelp ;
86
94
fn ( ) ;
87
- } ) ;
95
+ }
88
96
89
97
function cmdSync ( ) {
90
98
expectArgCount ( 2 ) ;
0 commit comments