moonscript icon indicating copy to clipboard operation
moonscript copied to clipboard

moonc adds directory to output paths

Open hlship opened this issue 8 years ago • 6 comments

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.

hlship avatar Oct 25 '17 22:10 hlship

Workaround: (cd src && moonc -o ../out .)

hlship avatar Oct 25 '17 22:10 hlship

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.

RyanSquared avatar Oct 29 '17 02:10 RyanSquared

moon -t out src/* doesn't work, same unwanted behavior.

hlship avatar Oct 29 '17 16:10 hlship

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?

RyanSquared avatar Oct 30 '17 04:10 RyanSquared

I think that's fine, did the same bug exist before the command line parser update?

leafo avatar Oct 30 '17 04:10 leafo

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.

RyanSquared avatar Oct 30 '17 04:10 RyanSquared