7-package.json: update version field

This commit is contained in:
rkiel
2017-10-07 08:27:33 -04:00
parent cc6675c94a
commit 657c88c14e
3 changed files with 26 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
require 'json'
module Shared
module Runnable
@@ -19,6 +21,25 @@ module Shared
exit
end
def update_package_json (version)
if File.exist? 'package.json'
package_json = File.read('package.json')
json = JSON.parse(package_json)
json['version'] = version
File.write('package.json', JSON.pretty_generate(json))
git_add 'package.json'
git_commit version
end
end
def git_add (path)
run_cmd "git add #{path}"
end
def git_commit (msg)
run_cmd "git commit -m '#{msg}'"
end
def git_show_branches
run_cmd "git branch"
end