broccolijs / fs-merger Goto Github PK
View Code? Open in Web Editor NEWLibrary which performs broccoli merging and funneling without actually copying files.
Library which performs broccoli merging and funneling without actually copying files.
It seems that every fs
operation will be calling getRootAndPrefix
:
https://github.com/SparshithNR/fs-merger/blob/021b9075fe08d28edb99c550bdae6b41080e3fa4/index.js#L59
We should avoid calling this so many times.
@SparshithNR - Since this is used by default by Broccoli, I think we should probably move it into the BroccoliJS org. Any objections?
In general with broccoli-merge-trees
rules, the "last one wins" (but only if you've specified { overwrite: true }
. This library also supports "last wins", but it still reads from each tree. See implementation here:
If we do indeed intend to support "last wins" we should update the implementations to avoid reading files only to throw away those results (e.g. we should iterate backwards and return the first match).
https://github.com/SparshithNR/fs-merger/blob/021b9075fe08d28edb99c550bdae6b41080e3fa4/index.js#L72
This error that is thrown suggests that only whitelisted operations are allowed. The operations in this constant are:
However, we also allow the end consumer to call any method on the fs-merger
itself:
This means that users in broccoli-land could do this.input.readdir
(note: not the sync version) and get this implementation:
https://github.com/SparshithNR/fs-merger/blob/021b9075fe08d28edb99c550bdae6b41080e3fa4/index.js#L156
let fsMerger = new FSMerger([`a`,`b`]);
let fileAt = fsMerger.fs.at(1).readFileSync('test.txt'); //errors
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number
at validateString (internal/validators.js:112:11)
at Object.isAbsolute (path.js:1030:5)
at FSMerger.handleOperation (node_modules/fs-merger/dist/index.js:51:15)
The broccoli PR does not use it AFAICT
๐
@thoov, pinging you before people start freaking out
It should raise an error.
Running: this.input.entries()
currently throws with:
> this.input.entries()
NodeError: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.isAbsolute (path.js:1136:5)
at FSMerger.handleOperation (/Users/spenner/src/stefanpenner/gql-experiment/node_modules/fs-merger/dist/index.js:54:39)
at eval (eval at build (/Users/spenner/src/stefanpenner/gql-experiment/index.js:7:5), <anonymous>:1:12)
at GQL.build (/Users/spenner/src/stefanpenner/gql-experiment/index.js:7:5)
at TransformNodeWrapper.build (/Users/spenner/src/stefanpenner/gql-experiment/node_modules/broccoli/dist/wrappers/transform-node.js:70:39)
at pipeline.then (/Users/spenner/src/stefanpenner/gql-experiment/node_modules/broccoli/dist/builder.js:118:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
This isn't super helpful, it should likely rather just assume the caller wants all relevant entries.
this.input.entries()
should likely perform like this.input.entries('.')
sh
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.