Join GitHub today
add test for fs.appendFile for valid file system flag #463
When calling fs.appendFile(path, data[, options], callback), within the options object we may include a file system flag (defaults to 'a' so that the file is opened for appending).
I would like to:
However it is not obvious to me why the user might have the option of choosing a flag other than 'a'. Is there any value in leaving it as an option? It seems to me that for this method, any selection would either cause it to behave as if it were opened using 'a', or else cause some kind of error.
Update: I ended up making two test cases for testing the default values ( #494 ). This revealed a bug in the the implementation of appendFile. I have submitted another PR ( #546 ) that fixes this (and tests against it).
changed the title from
add tests for fs.appendFile for valid file system flags
add test for fs.appendFile for valid file system flags
Sep 23, 2018
See https://nodejs.org/api/fs.html#fs_file_system_flags and https://github.com/nodejs/node/blob/eef072fa083f05f84fa6ca1908472eb228095a38/lib/fs.js#L1227-L1238 for what node does. Filer needs to support the same options as node, even if we end up ignoring the. I agree that if you pass certain flags it should fail, but that's a reasonable test to write. My advice: try passing different flags to node's version, see what it does, write tests for Filer that expect the same behaviour.