Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused lib/npm relics #6482

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions lib/npm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const EventEmitter = require('events')
const { resolve, dirname, join } = require('path')
const Config = require('@npmcli/config')
const chalk = require('chalk')
Expand All @@ -20,7 +19,7 @@ const updateNotifier = require('./utils/update-notifier.js')
const pkg = require('../package.json')
const { commands, aliases } = require('./utils/cmd-list.js')

class Npm extends EventEmitter {
class Npm {
static get version () {
return pkg.version
}
Expand All @@ -32,7 +31,6 @@ class Npm extends EventEmitter {
#command = null
#runId = new Date().toISOString().replace(/[.:]/g, '_')
#loadPromise = null
#tmpFolder = null
#title = 'npm'
#argvClean = []
#chalk = null
Expand Down Expand Up @@ -66,7 +64,6 @@ class Npm extends EventEmitter {
// prefix to `npmRoot` since that is the first dir it would encounter when
// doing implicit detection
constructor ({ npmRoot = dirname(__dirname), argv = [], excludeNpmCwd = false } = {}) {
super()
this.#npmRoot = npmRoot
this.config = new Config({
npmPath: this.#npmRoot,
Expand Down Expand Up @@ -462,15 +459,6 @@ class Npm extends EventEmitter {
return usage(this)
}

// XXX add logging to see if we actually use this
get tmp () {
if (!this.#tmpFolder) {
const rand = require('crypto').randomBytes(4).toString('hex')
this.#tmpFolder = `npm-${process.pid}-${rand}`
}
return resolve(this.config.get('tmp'), this.#tmpFolder)
}

// output to stdout in a progress bar compatible way
output (...msg) {
log.clearProgress()
Expand Down
4 changes: 0 additions & 4 deletions test/lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ t.test('npm.load', async t => {
mockGlobals(t, { process: { platform: 'win32' } })
t.equal(npm.bin, npm.globalBin, 'bin is global bin in windows mode')
t.equal(npm.dir, npm.globalDir, 'dir is global dir in windows mode')

const tmp = npm.tmp
t.match(tmp, String, 'npm.tmp is a string')
t.equal(tmp, npm.tmp, 'getter only generates it once')
})

await t.test('forceful loading', async t => {
Expand Down