diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-12-15 13:33:02 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-12-15 13:33:02 +0100 |
commit | 9a7623de1458f799baa109d0afbed08547874550 (patch) | |
tree | 5e62c0c22e680666a3d7729b5b8f01051cade2f7 /compute_scripts.awk | |
parent | 58fe4c7d806359bed299f74ba56902ab396a6ed1 (diff) | |
download | browser-extension-9a7623de1458f799baa109d0afbed08547874550.tar.gz browser-extension-9a7623de1458f799baa109d0afbed08547874550.zip |
facilitate mocking imported values
Diffstat (limited to 'compute_scripts.awk')
-rw-r--r-- | compute_scripts.awk | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compute_scripts.awk b/compute_scripts.awk index 3f237e1..3d8a5b0 100644 --- a/compute_scripts.awk +++ b/compute_scripts.awk @@ -88,12 +88,12 @@ function print_file(filename, line) { close(filename) } -function print_imports_code(filename, i, count, import_name) { +function print_imports_code(filename, declarator, i, count, import_name) { count = import_counts[filename] for (i = 1; i <= count; i++) { import_name = imports[filename,i] - printf "const %s = window.haketilo_exports.%s;\n", - import_name, import_name + printf "%s %s = window.haketilo_exports.%s;\n", + declarator, import_name, import_name } } @@ -105,8 +105,11 @@ function print_exports_code(filename, i, count, export_name) { } } -function partially_wrap_file(filename) { - print_imports_code(filename) +function partially_wrap_file(filename, declarator) { + if (!declarator) + declarator = "const" + + print_imports_code(filename, declarator) printf "\n\n" print_file(filename) @@ -197,7 +200,7 @@ BEGIN { if (compute_dependencies(root_filename) > 0) exit 1 } else if (operation == "partially_wrapped_code") { - partially_wrap_file(root_filename) + partially_wrap_file(root_filename, "let") } else if (operation == "wrapped_code") { wrap_file(root_filename) } else { |