procodile 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7feabe360a0d490ac91076744fd7f782d39eebd0
4
- data.tar.gz: 71e2007d58331378e50d47263f12dee80b35d103
3
+ metadata.gz: 52606401641f665e09ce9beae6a752e70e3a680a
4
+ data.tar.gz: 052b223485baa0c66d5f67a3ff52afb9ed5a4ed4
5
5
  SHA512:
6
- metadata.gz: ee34c71d613246a255baaa0c9d2a6bf43be1ed845bd0001413c3e1cf45bc4b43eb7fb39563c79483ced396a277158a11f65348e82791340db699cf4f7e847089
7
- data.tar.gz: d6f501fbb6997231185507fcddd508446399a75b74eb53fa519f922c54d5eaecfb7e1c12f909407b056d1122b80baa9e3dfb1f2d279abffd3093e19667632f16
6
+ metadata.gz: 9c97e8abbcade5ed3e51553ff97a0b658f69a326e4afc84029070e288b5882ea8b4b2d5c6e22bcfae15afd31c2305ac30a353a5c20e39849be41ddeafbf40fbb
7
+ data.tar.gz: eae3e1a71001a027ab132e5797a59c1b78e383bd6aac1f68dfe8ccba7b33afe81db7efc5ed8bf09212a7606d82fade99da6afb54f5e062eb480d75aad9cb8762
data/bin/procodile CHANGED
@@ -62,7 +62,7 @@ if ap.ambiguous?
62
62
  if ENV['PROCODILE_APP_ID']
63
63
  ap.set_app(ENV['PROCODILE_APP_ID'].to_i)
64
64
  elsif ap.app_options.empty?
65
- $stderr.puts "Error: Could not find procodile in #{FileUtils.pwd}/Procfile".color(31)
65
+ $stderr.puts "Error: Could not find Procfile in #{FileUtils.pwd}/Procfile".color(31)
66
66
  exit 1
67
67
  else
68
68
  puts "There are multiple applications configured in #{global_config_path}"
@@ -91,17 +91,17 @@ module Procodile
91
91
  def find_root_and_procfile(pwd, root, procfile)
92
92
  if root && procfile
93
93
  # The user has provided both the root and procfile, we can use these
94
- @root = File.expand_path(root)
95
- @procfile = File.expand_path(procfile, @root)
94
+ @root = expand_path(root)
95
+ @procfile = expand_path(procfile, @root)
96
96
  elsif root && procfile.nil?
97
97
  # The user has given us a root, we can assume they want to use the procfile
98
98
  # from the root
99
- @root = File.expand_path(root)
99
+ @root = expand_path(root)
100
100
  @procfile = File.join(@root, 'Procfile')
101
101
  elsif root.nil? && procfile
102
102
  # The user has given us a procfile but no root. We will assume the procfile
103
103
  # is in the root of the directory
104
- @procfile = File.expand_path(procfile)
104
+ @procfile = expand_path(procfile)
105
105
  @root = File.dirname(@procfile)
106
106
  else
107
107
  # The user has given us nothing. We will check to see if there's a Procfile
@@ -130,10 +130,10 @@ module Procodile
130
130
  end
131
131
 
132
132
  def global_options_for_path(root)
133
- root = File.expand_path(root)
134
- if @global_options.is_a?(Hash) && @global_options['root'] && File.expand_path(@global_options['root']) == root
133
+ root = expand_path(root)
134
+ if @global_options.is_a?(Hash) && @global_options['root'] && expand_path(@global_options['root']) == root
135
135
  @global_options
136
- elsif @global_options.is_a?(Array) && option = @global_options.select { |o| o['root'] && File.expand_path(o['root']) == root }.first
136
+ elsif @global_options.is_a?(Array) && option = @global_options.select { |o| o['root'] && expand_path(o['root']) == root }.first
137
137
  option
138
138
  else
139
139
  nil
@@ -146,5 +146,18 @@ module Procodile
146
146
  @environment = options['environment'] if options['environment']
147
147
  end
148
148
 
149
+ def expand_path(path, root = nil)
150
+ # Remove trailing slashes for normalization
151
+ path = path.gsub(/\/\z/, '')
152
+ if path =~ /\//
153
+ # If the path starts with a /, it's absolute. Do nothing.
154
+ path
155
+ else
156
+ # Otherwise, if there's a root provided, it should be from the root
157
+ # of that otherwise from the root of the current directory.
158
+ root ? File.join(root, path) : File.join(@pwd, path)
159
+ end
160
+ end
161
+
149
162
  end
150
163
  end
data/lib/procodile/cli.rb CHANGED
@@ -359,7 +359,15 @@ module Procodile
359
359
  desc "Run a command within the environment"
360
360
  command def run
361
361
  desired_command = ARGV.drop(1).join(' ')
362
- exec(@config.environment_variables, desired_command)
362
+ if desired_command.length == 0
363
+ raise Error, "You need to specify a command to run (e.g. procodile run -- rake db:migrate)"
364
+ else
365
+ begin
366
+ exec(@config.environment_variables, desired_command)
367
+ rescue Errno::ENOENT => e
368
+ raise Error, e.message
369
+ end
370
+ end
363
371
  end
364
372
 
365
373
  #
@@ -369,7 +377,11 @@ module Procodile
369
377
  command def console
370
378
  if cmd = @config.console_command
371
379
  environment = @config.environment_variables
372
- exec(environment, cmd)
380
+ begin
381
+ exec(environment, cmd)
382
+ rescue Errno::ENOENT => e
383
+ raise Error, e.message
384
+ end
373
385
  else
374
386
  raise Error, "No console command has been configured in the Procfile"
375
387
  end
@@ -1,3 +1,3 @@
1
1
  module Procodile
2
- VERSION = '1.0.13'
2
+ VERSION = '1.0.14'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procodile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -76,4 +76,3 @@ specification_version: 4
76
76
  summary: This gem will help you run Ruby processes from a Procfile on Linux servers
77
77
  in the background.
78
78
  test_files: []
79
- has_rdoc: