Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save westonganger/154293976a2afc6d643b to your computer and use it in GitHub Desktop.
Save westonganger/154293976a2afc6d643b to your computer and use it in GitHub Desktop.
Add the Ignore Cache option to Ionic to fix this issue: https://github.com/driftyco/ionic-cli/issues/420
npm_global_path = File.join(system("npm config get prefix"), "lib/node_modules")
file_name = File.join(npm_global_path, "ionic/lib/tasks/cliTasks.js")
File.open(file_name, 'r+') do |f|
orig_str = "'--splash|-s': {"
str = "'--ignore-cache|-c': { title: 'Ignoring cached resources', boolean: true },#{orig_str}"
f.write File.read(file_name).gsub(orig_str, str)
end
file_name = File.join(npm_global_path, "ionic/node_modules/ionic-app-lib/lib/resources.js")
File.open(file_name, 'r+') do |f|
contents = File.read(file_name)
orig_str = "queueResTypeImages('icon'"
str = "#{orig_str},options.c || options['ignore-cache']"
contents.gsub!(orig_str, str)
orig_str = "queueResTypeImages('splash'"
str = "#{orig_str},options.c || options['ignore-cache']"
contents.gsub!(orig_str, str)
orig_str = "queueResTypeImages(resType"
str = "#{orig_str}, ignoreCache"
contents.gsub!(orig_str, str)
orig_str = "Settings.cacheImages && fs.existsSync"
str = "!ignoreCache && #{orig_str}"
contents.gsub!(orig_str, str)
f.write contents
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment