mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
limit length of simulator files
This commit is contained in:
parent
3588526768
commit
95bad32c92
2 changed files with 11 additions and 0 deletions
2
www/tutorial/.gitignore
vendored
2
www/tutorial/.gitignore
vendored
|
@ -12,5 +12,7 @@ app/*.map
|
|||
app/**/*.js
|
||||
app/**/*.map
|
||||
|
||||
dist
|
||||
|
||||
!webpack.config.js
|
||||
scripts/simulator/filesystem/examples/profile/*
|
||||
|
|
|
@ -4,6 +4,7 @@ require 'yaml'
|
|||
require 'github/markup'
|
||||
require 'json'
|
||||
require 'shellwords'
|
||||
require 'digest'
|
||||
|
||||
# global config
|
||||
input_dir = File.expand_path(File.join(File.dirname(__FILE__), '../content'))
|
||||
|
@ -14,6 +15,14 @@ simulator = 'inspec-simulator'
|
|||
def create_key(command)
|
||||
formatted_command = command.gsub(/\W/, '_')
|
||||
not_too_long = formatted_command.gsub(/_{2,}/, '_')
|
||||
# ensure file names do not get to long (for Windows)
|
||||
if not_too_long.length > 40
|
||||
hash = Digest::MD5.hexdigest not_too_long
|
||||
# hard_cut at 40 chars
|
||||
not_too_long = not_too_long.slice(0..40)
|
||||
# find last underscore and change end with hash
|
||||
not_too_long.gsub!(/_[^_]*$/, '_' + hash)
|
||||
end
|
||||
not_too_long + '.txt'
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue