@@ -17,7 +17,7 @@ dry_run_help = [
17
17
18
18
option = { }
19
19
OptionParser . new do |opt |
20
- opt . on ( '-e' , '--env' , "input access key and secret key from '.env' file" ) { |v | option [ :env ] = v }
20
+ opt . on ( '-e' , '--env' , "input access key, secret key, syncdir and bucket name from '.env' file" ) { |v | option [ :env ] = v }
21
21
opt . on ( '--dry-run' , *dry_run_help ) { |v | option [ :dry_run ] = v }
22
22
opt . on ( '--no-ignore' , 'all files are targeted for upload' ) { |v | option [ :no_ignore ] = v }
23
23
opt . on ( '--ignore=VALUE' , 'set your ignore file' ) { |v | option [ :ignore ] = v }
@@ -36,21 +36,15 @@ class Object
36
36
end
37
37
38
38
def read_env env_file
39
- elements = {
40
- 'S3_ACCESS_KEY' => '' ,
41
- 'S3_SECRET_KEY' => ''
42
- }
43
-
39
+ elements = { }
44
40
begin
45
41
File . open ( env_file ) do |file |
46
42
file . each_line do |line |
47
43
rows = line . split ( '=' )
48
44
elem = rows . first . try ( :strip )
49
- if elements [ elem ]
50
- value = rows . last . try ( :strip )
51
- next unless value
52
- elements [ elem ] = value . gsub ( '"' , '' ) . gsub ( '\'' , '' )
53
- end
45
+ value = rows . last . try ( :strip )
46
+ next unless value
47
+ elements [ elem ] = value . gsub ( '"' , '' ) . gsub ( '\'' , '' )
54
48
end
55
49
end
56
50
rescue => e
@@ -69,8 +63,8 @@ if option[:env]
69
63
env = read_env ( '.env' )
70
64
access_key = env [ 'S3_ACCESS_KEY' ]
71
65
secret_key = env [ 'S3_SECRET_KEY' ]
72
- upload_dir = ARGV [ 0 ]
73
- bucket_name = ARGV [ 1 ]
66
+ upload_dir = env [ 'DEPLOY_DIR' ] || ARGV [ 0 ]
67
+ bucket_name = env [ 'S3_BUCKET_NAME' ] || ARGV [ 1 ]
74
68
else
75
69
if ARGV . length < 4
76
70
puts "too few arguments."
0 commit comments