Merck / pkglite

Compact Package Representations
https://merck.github.io/pkglite/
GNU General Public License v3.0
30 stars 4 forks source link

Pack one file #39

Closed SHAESEN2 closed 1 year ago

SHAESEN2 commented 1 year ago

When packing only one file, I get an error that I traced back to the following piece of code:

idx_content_end <- c(idx_pkg[2L:nblocks] - 2L, nlines)

This line of code identifies the end of each block. If you have three files packed in the .txt file it will look for:

When you only pack one file, this logic does not work because nblocks is 1.

This can be solved by eg

if (nblocks == 1) { idx_content_end <- c(nlines) } else if (nblocks>1) { idx_content_end <- c(idx_pkg[2L:nblocks] - 2L, nlines) }

It would be good to include a unit test for this.

nanxstats commented 1 year ago

So if you have one file, does it make more sense to use/exchange it as-is? Just a thought 🤔

Alternatively, you could build an R package for it, which (I know) is a huge ask sometimes... but that will almost surely make it more than two or three files.

SHAESEN2 commented 1 year ago

It makes sense for experimentation and training purposes. If you are not inclined to add a few lines of code to fix the issue, could you consider adding an informative message or documenting the behavior?

nanxstats commented 1 year ago

Hmm, good question, but after some rethinking, I'm still going to say no, and here is my reasoning:

  1. For experimentation and training purposes, any R package scaffolding tool such as usethis::create_package() that creates a proper package will create more than one file.
  2. It's common sense that more that one file will be involved under the context of packing a proper R package, so emphasizing an expected behavior would sound a bit unnecessary to me.

Thanks for bringing this up, though!