Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Metalsmith.static method for pass-through file copy #361

Open
webketje opened this issue Jan 22, 2022 · 0 comments
Open

Add Metalsmith.static method for pass-through file copy #361

webketje opened this issue Jan 22, 2022 · 0 comments
Assignees
Labels
Milestone

Comments

@webketje
Copy link
Member

Adding a metalsmith.static('media/**') method with a signature similar to metalsmith.ignore would allow metalsmith to use native NodeJs fs.copyFile to do a pass-through file copy, which would avoid overhead from reading files into memory that are then not even processed.

TBD whether files matched with metalsmith.static should figure as object keys in the Files object.
If they do, they must not have valid files as values. Still this might break backwards-compatibility with some plugins.

'copiedFile.zip': { }
//or
'copiedFile.zip': null

So a better option would perhaps be to have metalsmith.static() (without arguments) return the list of matches (so plugins know exactly which files will be/ have been copied over)

In any case a test is needed with a large file to see the effect on perf & interoperability

Note: aligning metalsmith.ignores() to return the ignored matches (instead of the existing & equally accessible ignores property)

@webketje webketje self-assigned this Jan 22, 2022
@webketje webketje added this to the v2.5 milestone Jan 22, 2022
@webketje webketje modified the milestones: v2.5, v2.6 Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant