Skip to content

Commit 22d1c58

Browse files
ericcornelissenljharb
authored andcommitted
[Refactor] Remove fs-access; use fs.access
Remove the no-longer-necessary dependency on fs-access [1] and use the built-in fs module's access function [2] instead. They are interchangeable as 1) the former is a polyfill for the latter and 2) there are no recorded breaking changes to the function signature in Node.js. In particular, the fs.access documentation specifies only one changes in the range of versions supported by licensee, which is irrelevant here (namely that the type of error thrown for non-callback callbacks changed). I decided to set the access mode to `R_OK` (from the default `F_OK`) as the access check is performed in preparation for reading the file (line 100). Note that `F_OK` is the only mode supported by fs-access, hence the absence of an access mode prior to this change. Note that the fs-access package is deprecated and therefore, in contrast to the built-in fs module, doesn't receive any updates anymore. -- 1. https://www.npmjs.com/package/fs-access 2. https://nodejs.org/docs/latest-v18.x/api/fs.html#fsaccesspath-mode-callback 3. https://github.com/jslicense/licensee.js/blob/9abd28fde91b5343a9b9322f6e5cb9547093febc/.github/workflows/ci.yml#L8
1 parent 801ed66 commit 22d1c58

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

licensee

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env node
2-
var access = require('fs-access')
32
var docopt = require('docopt')
43
var fs = require('fs')
54
var has = require('has')
@@ -87,7 +86,7 @@ if (options['--init']) {
8786
}
8887
checkDependencies()
8988
} else {
90-
access(configurationPath, function (error) {
89+
fs.access(configurationPath, fs.constants.R_OK, function (error) {
9190
if (error) {
9291
die(
9392
[

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"@npmcli/arborist": "^6.1.2",
1414
"correct-license-metadata": "^1.4.0",
1515
"docopt": "^0.6.2",
16-
"fs-access": "^2.0.0",
1716
"has": "^1.0.3",
1817
"npm-license-corrections": "^1.6.2",
1918
"semver": "^7.3.8",

0 commit comments

Comments
 (0)