Closed 3cp closed 3 years ago
fillStatsArray needs to be updated to support bigint too.
There is one more stat array in fs binding: bigintStatValues
needs to be implemented.
> process.binding('fs')
BaseObject {
statValues: Float64Array(36) [
16777220, 33188, 1, 501,
20, 0, 4096, 102210022,
0, 0, 1620469235, 811292225,
1620469235, 811292225, 1620469235, 811292225,
1620469235, 811292225, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
],
bigintStatValues: BigUint64Array(36) [
16777220n, 33188n, 1n,
501n, 20n, 0n,
4096n, 98442580n, 1270n,
8n, 1615088646n, 360473114n,
1615088646n, 243729709n, 1615088646n,
243729709n, 1615082739n, 729366298n,
0n, 0n, 0n,
0n, 0n, 0n,
0n, 0n, 0n,
0n, 0n, 0n,
0n, 0n, 0n,
0n, 0n, 0n
],
Since nodejs v10.0.0, the internal return of binding.stat/lstat/fstat are now Float64Array or BigUint64Array. The old nodejs returns a Stats object with properties like stats.mode
.
I am trying to make it work for both old and new nodejs. The implementation might work (I have not tested enough), but there are tons of test code needs two copies (one for old, and one for new).
Since nodejs v10.0.0 is already EOL, @tschaub should we consider for a major version upgrade to target only nodejs v12+? The benefits are:
Since nodejs v10.0.0 is already EOL, @tschaub should we consider for a major version upgrade to target only nodejs v12+?
Sounds like a good plan.
The added code are for test. The code in lib folder is 100 LOC less.
huocp@chunpengs-mbp ~/g/mock-fs (stats-bigint)> cloc lib/
12 text files.
12 unique files.
0 files ignored.
github.com/AlDanial/cloc v 1.88 T=0.03 s (423.4 files/s, 100451.6 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
JavaScript 12 282 836 1729
-------------------------------------------------------------------------------
SUM: 12 282 836 1729
-------------------------------------------------------------------------------
huocp@chunpengs-mbp ~/g/mock-fs (stats-bigint)> git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
huocp@chunpengs-mbp ~/g/mock-fs (main)> cloc lib/
12 text files.
12 unique files.
0 files ignored.
github.com/AlDanial/cloc v 1.88 T=0.03 s (410.1 files/s, 103698.1 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
JavaScript 12 295 908 1831
-------------------------------------------------------------------------------
SUM: 12 295 908 1831
-------------------------------------------------------------------------------
I will get a win10 box to test the NaN uid/gid thing.
GitHub actions still wants to see nodejs 6/8/10 results. I don't know how to remove them in the checks.
Windows now uses 0 for uid and gid, not NaN anymore (this is probably a change in nodejs v10.0.0 when stats is a Float64Array internally).
@tschaub after merging this one, you might want to update README to clarify nodejs support in mock-fs v4 and v5. Also I think it's a good idea to highlight the missing support of fs.opendir #319 which will unlikely be fixed in future.
@tschaub I will do a small cleanup of uid/gid for Windows soon. It's unnecessary to use NaN internally in our code.
mock-fs@5.0.0-beta.1
includes this change.
@tschaub can you release v5.0.0?
closes #321
BREAKING CHANGE: drop support of Nodejs before v12.0.0