summaryrefslogtreecommitdiff
path: root/lib/fs.js
AgeCommit message (Collapse)Author
2019-12-03fs: fix existsSync for invalid symlink at win32Rongjian Zhang
Fixes: https://github.com/nodejs/node/issues/30538 PR-URL: https://github.com/nodejs/node/pull/30556 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-11-30lib: use static Number properties from primordialsMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/30686 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-11-25lib: flatten access to primordialsMichaël Zasso
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-19fs: make FSStatWatcher.start privateLucas Holmquist
An instance of FSStatWatcher is returned when a user calls fs.watchFile, which will call the start method. A user can't create an instance of a FSStatWatcher directly. If the start method is called by a user it is a noop since the watcher has already started. This "Class" is currently undocumented. PR-URL: https://github.com/nodejs/node/pull/29971 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-11-08fs: change var to letNadya
PR-URL: https://github.com/nodejs/node/pull/30318 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2019-10-12fs: make FSWatcher.start privateLucas Holmquist
* This is a semver-major change to rename the FSWatcher.start function to FSWatcher._start to make it private The motivation here is that it serves no purpose to the end user. An instance of FSWatcher is returned when a user calls fs.watch, which will call the start method. A user can't create an instance of a FSWatcher directly. If the start method is called by a user it is a noop since the watcher has already started. Calling start after a watcher has closed is also a noop PR-URL: https://github.com/nodejs/node/pull/29905 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-10-09http2: allow passing FileHandle to respondWithFDAnna Henningsen
This seems to make sense if we want to promote the use of `fs.promises`, although it’s not strictly necessary. PR-URL: https://github.com/nodejs/node/pull/29876 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-10-08fs: introduce `opendir()` and `fs.Dir`Jeremiah Senkpiel
This adds long-requested methods for asynchronously interacting and iterating through directory entries by using `uv_fs_opendir`, `uv_fs_readdir`, and `uv_fs_closedir`. `fs.opendir()` and friends return an `fs.Dir`, which contains methods for doing reads and cleanup. `fs.Dir` also has the async iterator symbol exposed. The `read()` method and friends only return `fs.Dirent`s for this API. Having a entry type or doing a `stat` call is deemed to be necessary in the majority of cases, so just returning dirents seems like the logical choice for a new api. Reading when there are no more entries returns `null` instead of a dirent. However the async iterator hides that (and does automatic cleanup). The code lives in separate files from the rest of fs, this is done partially to prevent over-pollution of those (already very large) files, but also in the case of js allows loading into `fsPromises`. Due to async_hooks, this introduces a new handle type of `DIRHANDLE`. This PR does not attempt to make complete optimization of this feature. Notable future improvements include: - Moving promise work into C++ land like FileHandle. - Possibly adding `readv()` to do multi-entry directory reads. - Aliasing `fs.readdir` to `fs.scandir` and doing a deprecation. Refs: https://github.com/nodejs/node-v0.x-archive/issues/388 Refs: https://github.com/nodejs/node/issues/583 Refs: https://github.com/libuv/libuv/pull/2057 PR-URL: https://github.com/nodejs/node/pull/29349 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-08-23fs: add recursive option to rmdir()cjihrig
This commit adds a recursive option to fs.rmdir(), fs.rmdirSync(), and fs.promises.rmdir(). The implementation is a port of the npm module rimraf. PR-URL: https://github.com/nodejs/node/pull/29168 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2019-08-19fs: use consistent buffer array validationcjihrig
This commit updates fs.writev() and fs.writevSync() to use the same validation method as filehandle.writev(). PR-URL: https://github.com/nodejs/node/pull/29186 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-08-19fs: validate writev fds consistentlycjihrig
This commit updates the recently added writev methods to validate file descriptors like the other fs methods do. PR-URL: https://github.com/nodejs/node/pull/29185 Refs: https://github.com/nodejs/node/pull/25925 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-08-19lib: rename validateSafeInteger to validateIntegercjihrig
validateInteger() was renamed to validateSafeInteger() in https://github.com/nodejs/node/pull/26572. However, this function also works with unsafe integers. This commit restores the old name, and adds some basic tests. PR-URL: https://github.com/nodejs/node/pull/29184 Refs: https://github.com/nodejs/node/pull/26572 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-08-16fs: add fs.writev() which exposes syscall writev()Anas Aboureada
fs with writev allow many buffers to be pushed to underlying OS APIs in one batch, so this should improve write speed to files. Refs: https://github.com/nodejs/node/issues/2298 PR-URL: https://github.com/nodejs/node/pull/25925 Fixes: https://github.com/nodejs/node/issues/2298 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-16fs: allow int64 offset in fs.write/writeSync/fd.writeZach Bjornson
Ref https://github.com/nodejs/node/issues/26563 PR-URL: https://github.com/nodejs/node/pull/26572 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-16fs: allow int64 offset in fs.read/readSync/fd.readZach Bjornson
Since v10.10.0, 'buf' can be any DataView, meaning the largest byteLength can be Float64Array.BYTES_PER_ELEMENT * kMaxLength = 17,179,869,176. 'offset' can now be up to 2**53 - 1. This makes it possible to tile reads into a large buffer. Breaking: now throws if read offset is not a safe int, is null or is undefined. Fixes https://github.com/nodejs/node/issues/26563 PR-URL: https://github.com/nodejs/node/pull/26572 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-16lib: rename validateInteger to validateSafeIntegerZach Bjornson
PR-URL: https://github.com/nodejs/node/pull/26572 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-16fs: add default options for *stat()Tony Brix
PR-URL: https://github.com/nodejs/node/pull/29114 Fixes: https://github.com/nodejs/node/issues/29113 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-08-07fs: validate fds as int32scjihrig
This commit updates the JS layer's validation of file descriptors to check for int32s >= 0 instead of uint32s. PR-URL: https://github.com/nodejs/node/pull/28984 Fixes: https://github.com/nodejs/node/issues/28980 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-30lib: removed unnecessary fs.realpath `options` arg check + testsAlex Pry
Removed duplicated check for options argument of fs.realpath. Added some tests which covering the cases for passing options arg as null. PR-URL: https://github.com/nodejs/node/pull/27909 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-26Revert "lib: print to stdout/stderr directly instead of using console"Richard Lau
This reverts commit 2b24ffae2240163a74ae11e49ee198e98abb07dc. Fixes: https://github.com/nodejs/node/issues/27819 PR-URL: https://github.com/nodejs/node/pull/27823 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-14fs: extract path conversion and validation to getValidatedPathZYSzys
Almost all path validations within our file system are combined with: ```js path = toPathIfFileURL(path); validatePath(path); ``` So simply extracted them out into `getValidatedPath` function to `internal/fs/utils.js` to DRY up the code and reduce duplicating them. PR-URL: https://github.com/nodejs/node/pull/27656 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-04-30lib: remove Reflect.apply where appropriateAnatoli Papirovski
Using Reflect.apply where the callback context does not need to change is unnecessary and less performant. PR-URL: https://github.com/nodejs/node/pull/27349 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-28lib: print to stdout/stderr directly instead of using consoleJoyee Cheung
This patch adds an internal function that prints to stdout or stderr by directly writing to the known file descriptor, and uses it internally in common cases to avoid the overhead of the console implementation. PR-URL: https://github.com/nodejs/node/pull/27320 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-12lib: enforce the use of Object from primordialsMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/27146 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2019-04-08fs: warn on non-portable mkdtemp() templatescjihrig
Refs: https://github.com/nodejs/node/issues/26435 PR-URL: https://github.com/nodejs/node/pull/26980 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-07fs: improve readFile performanceRuben Bridgewater
This increases the maximum buffer size per read to 512kb when using `fs.readFile`. This is important to improve the read performance for bigger files. PR-URL: https://github.com/nodejs/node/pull/27063 Refs: https://github.com/nodejs/node/issues/25741 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jamie Davis <davisjam@vt.edu>
2019-04-04errors: add more information in case of invalid callbacksRuben Bridgewater
This adds the actual callback that is passed through to the error message in case an ERR_INVALID_CALLBACK error is thrown. PR-URL: https://github.com/nodejs/node/pull/27048 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-04-03lib: force using primordials for JSON, Math and ReflectMichaël Zasso
Use the "no-restricted-globals" ESLint rule to lint for it. PR-URL: https://github.com/nodejs/node/pull/27027 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-02fs: remove experimental warning for fs.promisesAnna Henningsen
This has been warning for long enough, without any API changes in the last few months. PR-URL: https://github.com/nodejs/node/pull/26581 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27benchmark,doc,lib: capitalize more commentsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/26849 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-03-27lib: consolidate arrayBufferView validationRuben Bridgewater
There are lots of places that validate for arrayBufferView and we have multiple functions that do the same thing. Instead, move the validation into `internal/validators` so all files can use that instead. There are more functions throughout the code that do the same but it takes some more work to fully consolidate all of those. PR-URL: https://github.com/nodejs/node/pull/26809 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27lib: rename validateMode to parseModeRuben Bridgewater
The function did not only validate the mode but it returns a new value depending on the input. Thus `validate` did not seem to be an appropriate name. PR-URL: https://github.com/nodejs/node/pull/26809 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-23lib: validate Error.captureStackTrace() callsRuben Bridgewater
This adds a custom eslint rule to verify that `Error.captureStackTrace()` is only called if necessary. In most cases the helper function should be used instead. PR-URL: https://github.com/nodejs/node/pull/26738 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-23lib: refactor Error.captureStackTrace() usageRuben Bridgewater
When using `Errors.captureStackFrames` the error's stack property is set again. This adds a helper function that wraps this functionality in a simple API that does not only set the stack including the `code` property but it also improves the performance to create the error. The helper works for thrown errors and errors returned from wrapped functions in case they are Node.js core errors. PR-URL: https://github.com/nodejs/node/pull/26738 Fixes: https://github.com/nodejs/node/issues/26669 Fixes: https://github.com/nodejs/node/issues/20253 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-10benchmark,doc,lib,test: capitalize commentsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/26483 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-02-28benchmark,doc,lib,test: capitalize commentsRuben Bridgewater
This updates a lot of comments. PR-URL: https://github.com/nodejs/node/pull/26223 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-02-09fs: remove redundant callback checkZYSzys
PR-URL: https://github.com/nodejs/node/pull/25160 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-09fs: remove useless internalFSZYSzys
PR-URL: https://github.com/nodejs/node/pull/25161 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-20lib: remove internal `util._extends()` usageRuben Bridgewater
This removes all internal calls to the deprecated `_extends()` function. It is slower than `Object.assign()` and the object spread notation since V8 6.8 and using the spread notation often also results in shorter code. PR-URL: https://github.com/nodejs/node/pull/25105 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-12-17doc,lib,test: capitalize comment sentencesRuben Bridgewater
This activates the eslint capitalize comment rule for comments above 50 characters. PR-URL: https://github.com/nodejs/node/pull/24996 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-15fs: make writeFile consistent with readFile wrt fdSakthipriyan Vairamani (thefourtheye)
As it is, `readFile` always reads from the current position of the file, if a file descriptor is used. But `writeFile` always writes from the beginning of the file. This patch fixes this inconsistency by making `writeFile` also to write from the current position of the file when used with a file descriptor. PR-URL: https://github.com/nodejs/node/pull/23709 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-12-10tools: capitalize sentencesRuben Bridgewater
This adds the `capitalized-comments` eslint rule to verify that actual sentences use capital letters as starting letters. It ignores special words and all lines below 62 characters. PR-URL: https://github.com/nodejs/node/pull/24808 Reviewed-By: Sam Ruby <rubys@intertwingly.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-12-04fs: simplify fs.promises warning logiccjihrig
fs.promises is lazy loaded. Instead of using a seaparate Boolean flag to track whether or not it has been loaded, just inspect the state of the lazy loaded module itself. PR-URL: https://github.com/nodejs/node/pull/24788 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-11-29win, fs: detect if symlink target is a directoryBartosz Sosnowski
On Windows creating a symlink to a directory will not work unless extra 'dir' parameter is passed. This adds a check if link target is a directory, and if so automatically use 'dir' when creating symlink. PR-URL: https://github.com/nodejs/node/pull/23724 Refs: https://github.com/nodejs/node/pull/23691 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-11-28lib: convert to arrow function in fs.jsexoego
PR-URL: https://github.com/nodejs/node/pull/24604 Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-11-16fs: make process.binding('fs') internalMasashi Hirano
Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/22478 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2018-11-07src: prefer param function check over args lengthShelley Vohr
PR-URL: https://github.com/nodejs/node/pull/23835 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
2018-11-06fs: remove unused catch bindingscjihrig
PR-URL: https://github.com/nodejs/node/pull/24079 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
2018-11-03fs: handle result of access binding directly in fs.existsSyncJoyee Cheung
Instead of throwing errors in fs.accessSync and then catching it, handle the result from the binding directly in fs.existsSync. Note that the argument validation errors still needs to be caught until we properly deprecate the don't-thrown-on-invalid-arguments behavior. PR-URL: https://github.com/nodejs/node/pull/24015 Fixes: https://github.com/nodejs/node/issues/24008 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-10-26fs: default open/openSync flags argument to 'r'Ben Noordhuis
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile(). PR-URL: https://github.com/nodejs/node/pull/23767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>