Skip to content

Commit 59921bc

Browse files
committed
deps: remove dep on @npmcli/fs
1 parent 397ba75 commit 59921bc

File tree

16 files changed

+85
-83
lines changed

16 files changed

+85
-83
lines changed

DEPENDENCIES.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ graph LR;
119119
npm-->npmcli-config["@npmcli/config"];
120120
npm-->npmcli-docs["@npmcli/docs"];
121121
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
122-
npm-->npmcli-fs["@npmcli/fs"];
123122
npm-->npmcli-git["@npmcli/git"];
124123
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
125124
npm-->npmcli-package-json["@npmcli/package-json"];
@@ -741,7 +740,6 @@ graph LR;
741740
npm-->npmcli-config["@npmcli/config"];
742741
npm-->npmcli-docs["@npmcli/docs"];
743742
npm-->npmcli-eslint-config["@npmcli/eslint-config"];
744-
npm-->npmcli-fs["@npmcli/fs"];
745743
npm-->npmcli-git["@npmcli/git"];
746744
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
747745
npm-->npmcli-package-json["@npmcli/package-json"];
@@ -854,7 +852,6 @@ graph LR;
854852
npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"];
855853
npmcli-docs-->tap;
856854
npmcli-docs-->yaml;
857-
npmcli-fs-->gar-promisify["@gar/promisify"];
858855
npmcli-fs-->semver;
859856
npmcli-git-->lru-cache;
860857
npmcli-git-->mkdirp;

lib/commands/completion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// as an array.
3030
//
3131

32-
const fs = require('@npmcli/fs')
32+
const fs = require('fs/promises')
3333
const nopt = require('nopt')
3434

3535
const { definitions, shorthands } = require('../utils/config/index.js')

lib/npm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { resolve, dirname, join } = require('path')
44
const Config = require('@npmcli/config')
55
const chalk = require('chalk')
66
const which = require('which')
7-
const fs = require('@npmcli/fs')
7+
const fs = require('fs/promises')
88

99
// Patch the global fs module here at the app level
1010
require('graceful-fs').gracefulify(require('fs'))
@@ -246,13 +246,13 @@ class Npm extends EventEmitter {
246246
// a cache dir, but we don't want to fail immediately since
247247
// the command might not need a cache dir (like `npm --version`)
248248
await this.time('npm:load:mkdirpcache', () =>
249-
fs.mkdir(this.cache, { recursive: true, owner: 'inherit' })
249+
fs.mkdir(this.cache, { recursive: true })
250250
.catch((e) => log.verbose('cache', `could not create cache: ${e}`)))
251251

252252
// its ok if this fails. user might have specified an invalid dir
253253
// which we will tell them about at the end
254254
await this.time('npm:load:mkdirplogs', () =>
255-
fs.mkdir(this.logsDir, { recursive: true, owner: 'inherit' })
255+
fs.mkdir(this.logsDir, { recursive: true })
256256
.catch((e) => log.verbose('logfile', `could not create logs-dir: ${e}`)))
257257

258258
// note: this MUST be shorter than the actual argv length, because it

lib/utils/exit-handler.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const os = require('os')
2-
const fs = require('@npmcli/fs')
2+
const fs = require('fs')
33

44
const log = require('./log-shim.js')
55
const errorMessage = require('./error-message.js')
@@ -186,11 +186,7 @@ const exitHandler = err => {
186186
file = `${npm.logPath}${file}`
187187
content = `'Log files:\n${npm.logFiles.join('\n')}\n\n${content.trim()}\n`
188188
try {
189-
fs.withOwnerSync(
190-
file,
191-
() => fs.writeFileSync(file, content),
192-
{ owner: 'inherit' }
193-
)
189+
fs.writeFileSync(file, content)
194190
detail.push(['', `\n\nFor a full report see:\n${file}`])
195191
} catch (err) {
196192
log.warn('', `Could not write error message to ${file} due to ${err}`)

lib/utils/log-file.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const rimraf = promisify(require('rimraf'))
55
const glob = promisify(require('glob'))
66
const MiniPass = require('minipass')
77
const fsMiniPass = require('fs-minipass')
8-
const fs = require('@npmcli/fs')
98
const log = require('./log-shim')
109

1110
const padZero = (n, length) => n.toString().padStart(length.toString().length, '0')
@@ -174,11 +173,7 @@ class LogFiles {
174173
// during process.on('exit') which has to be synchronous. So in order
175174
// to never drop log messages, it is easiest to make it sync all the time
176175
// and this was measured to be about 1.5% slower for 40k lines of output
177-
const logStream = fs.withOwnerSync(
178-
f,
179-
() => new fsMiniPass.WriteStreamSync(f, { flags: 'a' }),
180-
{ owner: 'inherit' }
181-
)
176+
const logStream = new fsMiniPass.WriteStreamSync(f, { flags: 'a' })
182177
if (count > 0) {
183178
// Reset file log count if we are opening
184179
// after our first file

lib/utils/timers.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const EE = require('events')
2-
const fs = require('@npmcli/fs')
2+
const fs = require('fs')
33
const log = require('./log-shim')
44

55
// This is an event emiiter but on/off
@@ -90,11 +90,7 @@ class Timers extends EE {
9090
return acc
9191
}, {}),
9292
}
93-
fs.withOwnerSync(
94-
this.file,
95-
() => fs.writeFileSync(this.file, JSON.stringify(content) + '\n'),
96-
{ owner: 'inherit' }
97-
)
93+
fs.writeFileSync(this.file, JSON.stringify(content) + '\n')
9894
} catch (e) {
9995
this.file = null
10096
log.warn('timing', `could not write timing file: ${e}`)

package-lock.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@npmcli/arborist",
1313
"@npmcli/ci-detect",
1414
"@npmcli/config",
15-
"@npmcli/fs",
1615
"@npmcli/map-workspaces",
1716
"@npmcli/package-json",
1817
"@npmcli/run-script",
@@ -93,7 +92,6 @@
9392
"@npmcli/arborist": "^6.0.0-pre.4",
9493
"@npmcli/ci-detect": "^3.0.0",
9594
"@npmcli/config": "^6.0.1",
96-
"@npmcli/fs": "^2.1.0",
9795
"@npmcli/map-workspaces": "^3.0.0",
9896
"@npmcli/package-json": "^3.0.0",
9997
"@npmcli/run-script": "^5.0.0",

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"@npmcli/arborist": "^6.0.0-pre.4",
6060
"@npmcli/ci-detect": "^3.0.0",
6161
"@npmcli/config": "^6.0.1",
62-
"@npmcli/fs": "^2.1.0",
6362
"@npmcli/map-workspaces": "^3.0.0",
6463
"@npmcli/package-json": "^3.0.0",
6564
"@npmcli/run-script": "^5.0.0",
@@ -134,7 +133,6 @@
134133
"@npmcli/arborist",
135134
"@npmcli/ci-detect",
136135
"@npmcli/config",
137-
"@npmcli/fs",
138136
"@npmcli/map-workspaces",
139137
"@npmcli/package-json",
140138
"@npmcli/run-script",

scripts/bundle-and-gitignore-deps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const packlist = require('npm-packlist')
55
const git = require('@npmcli/git')
66
const { resolve, join, relative } = require('path')
77
const localeCompare = require('@isaacs/string-locale-compare')('en')
8-
const fs = require('@npmcli/fs')
8+
const fs = require('fs/promises')
99
const PackageJson = require('@npmcli/package-json')
1010

1111
const RM_FLAG = '--remove-ignored-files'

test/lib/commands/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MockRegistry = require('../../fixtures/mock-registry.js')
44
const mockGlobals = require('../../fixtures/mock-globals')
55

66
const cacache = require('cacache')
7-
const fs = require('@npmcli/fs')
7+
const fs = require('fs')
88
const path = require('path')
99

1010
const pkg = 'test-package'

0 commit comments

Comments
 (0)