changing file permisisons

This commit is contained in:
Alex Windett 2017-02-17 15:42:52 +00:00
parent 21665eaf39
commit b7a8ddb0bc
3 changed files with 59 additions and 2 deletions

View File

@ -19,7 +19,7 @@ running `make`, make continues without any errors, then you are good to go. [nod
is also needed if deployment to Triton is required.
```
make && make install
make && make install
```
Then to run each individual component locally (subject to change).

57
bin/sketch Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env ruby
require 'fileutils'
PROGNAME = 'pre-commit (auto-generate sketch previews)'
def main
progress "Installing sketchtool"
system!(%W[/Applications/Sketch.app/Contents/Resources/sketchtool/install.sh])
progress "Looking for changed or added .sketch files"
diff_output = capture!(%W[git diff --name-only --cached --pretty=format:])
sketch_files = diff_output.split("\n").grep(/\.sketch\z/)
if sketch_files.empty?
progress "No sketch files to create preview images for in this commit!"
end
puts sketch_files
sketch_files.each do |f|
unless File.exist?(f)
progress "#{f} does not exist (anymore?)"
next
end
png_output_dir = f.sub(/\.sketch\z/, '') + '-sketch-previews'
progress "deleting old previews"
FileUtils.rm_rf(png_output_dir)
progress "exporting pages"
cmd = %W[sketchtool --overwriting=YES --output=#{png_output_dir} export pages #{f}]
system!(cmd)
progress "adding to git"
system!(%W[git add #{png_output_dir}])
end
end
def system!(cmd)
puts "running: #{cmd.join(' ')}"
abort failure_message(cmd) unless system(*cmd)
end
def capture!(cmd)
puts "capturing: #{cmd.join(' ')}"
result = IO.popen(cmd) { |io| io.read }
abort failure_message(cmd) unless $?.success?
result
end
def failure_message(cmd)
"#{PROGNAME}: command failed: #{cmd.join(' ')}"
end
def progress(msg)
puts "#{PROGNAME}: #{msg}"
end
main

View File

@ -14,7 +14,7 @@
},
"scripts": {
"test": "make test",
"precommit": "make -j4 lint",
"precommit": "make -j4 lint && ./bin/sketch",
"prepush": "make test"
},
"dependencies": {