moonscript
moonscript copied to clipboard
moonc adds directory to output paths
When running moonc on a directory, with output to a different directory, an unwanted extra folder is created.
15:35:10 ~/workspaces/hlship/rejeweled > tree src
src
├── [ 259] conf.lua
├── [ 814] gemgrid.lua
├── [ 136] img
│ └── [ 20K] match3_sheet.png
├── [1.8K] main.moon
├── [ 511] shapes.moon
└── [ 157] utils.lua
1 directory, 6 files
15:35:12 ~/workspaces/hlship/rejeweled > moonc -t out src
Built src/main.moon
Built src/shapes.moon
15:35:19 ~/workspaces/hlship/rejeweled > tree out
out
└── [ 136] src
├── [2.1K] main.lua
└── [ 566] shapes.lua
1 directory, 2 files
I would expect the .lua files to be directly inside the out folder, not in out/src.
Workaround: (cd src && moonc -o ../out .)
If I recall correctly, the reason this happens is due to how I made the output code to a custom directory work, when tweaking with it. The issue is that you can compile more than one thing at a time, so you have to think about what happens if you use moonc -t out src1 src2? If src1/init.lua exists and src2/init.lua exists... what happens then? If you want the files to not be put in out/src, then you should use moonc -t out src/* instead.
moon -t out src/* doesn't work, same unwanted behavior.
Oh, I just reailzed why that wouldn't actually work - for the same reason that it wouldn't normally. @leafo should we add in a case to act like rsync does? i.e. moonc -t out src makes out/src and moonc -t out src/ makes out/ and puts the files from src directly in there?
I think that's fine, did the same bug exist before the command line parser update?
if you mean the switch to argparse versus alt-getopt, I'm pretty sure it did; I didn't change any functionality of how things currently worked, just renamed a few things and made a small bit for getting the arg count.