def _wrap_js_content(self, path): template = '''"use strict"; (function() { var exports = {}; %s })();''' replace_file_content(path, lambda c: template % c)
def _wrap_js_module(self, extension_out_path, path): template = '''"use strict"; _kangoLoader.add("%s", function(require, exports, module) { %s });''' module_id = os.path.relpath(path, extension_out_path).replace('.js', '').replace('\\', '/') replace_file_content(path, lambda c: template % (module_id, c))
def _wrap_js_module(self, extension_out_path, path): template = """"use strict"; _kangoLoader.add("%s", function(require, exports, module) { %s });""" module_id = os.path.relpath(path, extension_out_path).replace(".js", "").replace("\\", "/") replace_file_content(path, lambda c: template % (module_id, c))
def patch_background_host(self, path, modules): replace_file_content(path, lambda c: self.insert_modules(c, modules))
def _add_text_to_beginning(self, path, text): replace_file_content(path, lambda c: text + c)
def _patch_chrome_manifest(self, path): replace_file_content(path, lambda c: c.replace(KEYWORDS['product'], self._info.package_id), 'ascii')