does exactly what the name says.
since both nu -c ast
and nu --ide-ast
do not retain all important information
this is for now regex-based and therefore limited.
use
andexport use
have to be the first command in a line or stand directly after a;
.- if either condition is met within a (multiline-) string it will get screwed up.
$NU_LIB_DIRS
are not supported. use relative imports instead.source
is not supported.- The conversion-script should be able to run on windows, but it has never been tested.
python3 merge_nu_files.py main_file.nu
A few steps to understand why it does what:
- FACT:
use
works the same on both files and in-file defined modules - SOLUTION: therefore this script just wraps files with
export module NAME {}
- PROBLEM:
/
can't be included in the name of a in-file module and duplicate names can exist with files. - SOLUTION: therefore this script generates randomised names for modules of the converted files
- PROBLEM: the names of the modules changed
- SOLUTION: since the name has changed we have to replace it wherever it has been importing (using regex)
- PROBLEM:
use foo.nu
now no longer offersfoo test
, but insteadRANDOM_TEXT test
due to the randomisation - SOLUTION:
use foo
anduse abc foo
both result infoo
, therefore just add a submodule with the original name below the generated name