Skip to content

Commit

Permalink
fix: remove unused lib/npm relics
Browse files Browse the repository at this point in the history
npm being an instance of EventEmitter and have a tmp public getter
were both unused. Since we do not have a public API we can make these
changes without it being a breaking change.
  • Loading branch information
lukekarrys committed May 21, 2023
1 parent 173bc89 commit 74ca0fd
Showing 1 changed file with 1 addition and 13 deletions.
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

0 comments on commit 74ca0fd

Please sign in to comment.