Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2020-12-15 21:38:51 +0300
committernlf <quitlahok@gmail.com>2020-12-15 21:38:51 +0300
commit78677010147340e078ecc852fe625ca73399867e (patch)
treed04e74a964ecff811577d613185df97132e0e0b7
parenta844b709dba837b2c5dabeb78548ba7cbfc7e5ab (diff)
remove some unused modulesnlf/remove-unused-modules
-rw-r--r--lib/utils/child-path.js9
-rw-r--r--lib/utils/completion/file-completion.js23
-rw-r--r--lib/utils/deep-sort-object.js14
-rw-r--r--lib/utils/git.js55
-rw-r--r--lib/utils/module-name.js38
5 files changed, 0 insertions, 139 deletions
diff --git a/lib/utils/child-path.js b/lib/utils/child-path.js
deleted file mode 100644
index 38b9df138..000000000
--- a/lib/utils/child-path.js
+++ /dev/null
@@ -1,9 +0,0 @@
-var path = require('path')
-var validate = require('aproba')
-var moduleName = require('../utils/module-name.js')
-
-module.exports = childPath
-function childPath (parentPath, child) {
- validate('SO', arguments)
- return path.join(parentPath, 'node_modules', moduleName(child))
-}
diff --git a/lib/utils/completion/file-completion.js b/lib/utils/completion/file-completion.js
deleted file mode 100644
index b32eda52d..000000000
--- a/lib/utils/completion/file-completion.js
+++ /dev/null
@@ -1,23 +0,0 @@
-module.exports = fileCompletion
-
-const mkdir = require('mkdirp')
-const glob = require('glob')
-
-function fileCompletion (root, req, depth, cb) {
- if (typeof cb !== 'function') {
- cb = depth
- depth = Infinity
- }
- mkdir(root).catch(cb).then(() => {
- // can be either exactly the req, or a descendent
- var pattern = root + '/{' + req + ',' + req + '/**/*}'
- var opts = { mark: true, dot: true, maxDepth: depth }
- glob(pattern, opts, function (er, files) {
- if (er)
- return cb(er)
- return cb(null, (files || []).map(function (f) {
- return f.substr(root.length + 1).replace(/^\/|\/$/g, '')
- }))
- })
- })
-}
diff --git a/lib/utils/deep-sort-object.js b/lib/utils/deep-sort-object.js
deleted file mode 100644
index 56f1854f1..000000000
--- a/lib/utils/deep-sort-object.js
+++ /dev/null
@@ -1,14 +0,0 @@
-var sortedObject = require('sorted-object')
-
-module.exports = function deepSortObject (obj) {
- if (obj == null || typeof obj !== 'object')
- return obj
- if (obj instanceof Array)
- return obj.map(deepSortObject)
-
- obj = sortedObject(obj)
- Object.keys(obj).forEach(function (key) {
- obj[key] = deepSortObject(obj[key])
- })
- return obj
-}
diff --git a/lib/utils/git.js b/lib/utils/git.js
deleted file mode 100644
index 299302b27..000000000
--- a/lib/utils/git.js
+++ /dev/null
@@ -1,55 +0,0 @@
-const exec = require('child_process').execFile
-const spawn = require('./spawn')
-const npm = require('../npm.js')
-const which = require('which')
-const git = npm.config.get('git')
-const log = require('npmlog')
-const noProgressTillDone = require('./no-progress-while-running.js').tillDone
-const { promisify } = require('util')
-
-exports.spawn = spawnGit
-exports.exec = promisify(execGit)
-exports.chainableExec = chainableExec
-exports.whichAndExec = whichAndExec
-
-function prefixGitArgs () {
- return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : []
-}
-
-function execGit (args, options, cb) {
- log.info('git', args)
- const fullArgs = prefixGitArgs().concat(args || [])
- return exec(git, fullArgs, options, noProgressTillDone(cb))
-}
-
-function spawnGit (args, options) {
- log.info('git', args)
- // If we're already in a git command (eg, running test as an exec
- // line in an interactive rebase) then these environment variables
- // will force git to operate on the current project, instead of
- // checking out/fetching/etc. whatever the user actually intends.
- options.env = options.env || Object.keys(process.env)
- .filter(k => !/^GIT/.test(k))
- .reduce((set, k) => {
- set[k] = process.env[k]
- return set
- }, {})
- return spawn(git, prefixGitArgs().concat(args || []), options)
-}
-
-function chainableExec () {
- var args = Array.prototype.slice.call(arguments)
- return [execGit].concat(args)
-}
-
-function whichAndExec (args, options, cb) {
- // check for git
- which(git, function (err) {
- if (err) {
- err.code = 'ENOGIT'
- return cb(err)
- }
-
- execGit(args, options, cb)
- })
-}
diff --git a/lib/utils/module-name.js b/lib/utils/module-name.js
deleted file mode 100644
index c58050e55..000000000
--- a/lib/utils/module-name.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var path = require('path')
-
-module.exports = moduleName
-module.exports.test = {}
-
-module.exports.test.pathToPackageName = pathToPackageName
-function pathToPackageName (dir) {
- if (dir == null)
- return ''
- if (dir === '')
- return ''
- var name = path.relative(path.resolve(dir, '..'), dir)
- var scoped = path.relative(path.resolve(dir, '../..'), dir)
- if (scoped[0] === '@')
- return scoped.replace(/\\/g, '/')
- return name.trim()
-}
-
-module.exports.test.isNotEmpty = isNotEmpty
-function isNotEmpty (str) {
- return str != null && str !== ''
-}
-
-var unknown = 0
-function moduleName (tree) {
- if (tree.name)
- return tree.name
- var pkg = tree.package || tree
- if (isNotEmpty(pkg.name) && typeof pkg.name === 'string')
- return pkg.name.trim()
- var pkgName = pathToPackageName(tree.path)
- if (pkgName !== '')
- return pkgName
- if (tree._invalidName != null)
- return tree._invalidName
- tree._invalidName = '!invalid#' + (++unknown)
- return tree._invalidName
-}