summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils
diff options
context:
space:
mode:
authorFallenRiteMonk <fallenritemonk@gmail.com>2018-04-05 11:52:34 -0400
committerMyles Borins <mylesborins@google.com>2018-04-05 16:01:07 -0400
commit25a816dcda7b1db0929501acfe13f2fe5119759b (patch)
treed3df4377a11dfb643b5976d2048d9bb4ee527903 /deps/npm/lib/utils
parentb29c36b80746733994257b7380245102bc3c4cd6 (diff)
downloadandroid-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.tar.gz
android-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.tar.bz2
android-node-v8-25a816dcda7b1db0929501acfe13f2fe5119759b.zip
deps: upgrade npm to 5.8.0
PR-URL: https://github.com/nodejs/node/pull/19560 Fixes: https://github.com/nodejs/node/issues/19271 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/lib/utils')
-rw-r--r--deps/npm/lib/utils/error-message.js32
-rw-r--r--deps/npm/lib/utils/parse-json.js3
-rw-r--r--deps/npm/lib/utils/stringify-package.js17
-rw-r--r--deps/npm/lib/utils/unsupported.js5
4 files changed, 51 insertions, 6 deletions
diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js
index 85504f5edc..cd31d7d714 100644
--- a/deps/npm/lib/utils/error-message.js
+++ b/deps/npm/lib/utils/error-message.js
@@ -23,8 +23,17 @@ function errorMessage (er) {
case 'EACCES':
case 'EPERM':
short.push(['', er])
- detail.push(['', ['\nPlease try running this command again as root/Administrator.'
- ].join('\n')])
+ detail.push([
+ '',
+ [
+ '\nThe operation was rejected by your operating system.',
+ (process.platform === 'win32'
+ ? 'It\'s possible that the file was already in use (by a text editor or antivirus),\nor that you lack permissions to access it.'
+ : 'It is likely you do not have the permissions to access this file as the current user'),
+ '\nIf you believe this might be a permissions issue, please double-check the',
+ 'permissions of the file and its containing directories, or try running',
+ 'the command again as root/Administrator (though this is not recommended).'
+ ].join('\n')])
break
case 'ELIFECYCLE':
@@ -52,6 +61,25 @@ function errorMessage (er) {
break
case 'EJSONPARSE':
+ const path = require('path')
+ // Check whether we ran into a conflict in our own package.json
+ if (er.file === path.join(npm.prefix, 'package.json')) {
+ const isDiff = require('../install/read-shrinkwrap.js')._isDiff
+ const txt = require('fs').readFileSync(er.file, 'utf8')
+ if (isDiff(txt)) {
+ detail.push([
+ '',
+ [
+ 'Merge conflict detected in your package.json.',
+ '',
+ 'Please resolve the package.json conflict and retry the command:',
+ '',
+ `$ ${process.argv.join(' ')}`
+ ].join('\n')
+ ])
+ break
+ }
+ }
short.push(['', er.message])
short.push(['', 'File: ' + er.file])
detail.push([
diff --git a/deps/npm/lib/utils/parse-json.js b/deps/npm/lib/utils/parse-json.js
index 5c0b959a0d..c4149d282d 100644
--- a/deps/npm/lib/utils/parse-json.js
+++ b/deps/npm/lib/utils/parse-json.js
@@ -1,6 +1,7 @@
'use strict'
+var parseJsonWithErrors = require('json-parse-better-errors')
var parseJSON = module.exports = function (content) {
- return JSON.parse(stripBOM(content))
+ return parseJsonWithErrors(stripBOM(content))
}
parseJSON.noExceptions = function (content) {
diff --git a/deps/npm/lib/utils/stringify-package.js b/deps/npm/lib/utils/stringify-package.js
new file mode 100644
index 0000000000..0cc9de0a36
--- /dev/null
+++ b/deps/npm/lib/utils/stringify-package.js
@@ -0,0 +1,17 @@
+'use strict'
+
+module.exports = stringifyPackage
+
+const DEFAULT_INDENT = 2
+const CRLF = '\r\n'
+const LF = '\n'
+
+function stringifyPackage (data, indent, newline) {
+ const json = JSON.stringify(data, null, indent || DEFAULT_INDENT)
+
+ if (newline === CRLF) {
+ return json.replace(/\n/g, CRLF) + CRLF
+ }
+
+ return json + LF
+}
diff --git a/deps/npm/lib/utils/unsupported.js b/deps/npm/lib/utils/unsupported.js
index b586d035ce..15fa7396d0 100644
--- a/deps/npm/lib/utils/unsupported.js
+++ b/deps/npm/lib/utils/unsupported.js
@@ -5,8 +5,7 @@ var supportedNode = [
{ver: '6', min: '6.0.0'},
{ver: '7', min: '7.0.0'},
{ver: '8', min: '8.0.0'},
- {ver: '9', min: '9.0.0'},
- {ver: '10', min: '10.0.0'}
+ {ver: '9', min: '9.0.0'}
]
var knownBroken = '<4.7.0'
@@ -26,7 +25,7 @@ exports.checkForBrokenNode = function () {
supportedNode.forEach(function (rel) {
if (semver.satisfies(nodejs.version, rel.ver)) {
console.error('Node.js ' + rel.ver + " is supported but the specific version you're running has")
- console.error(`a bug known to break npm. Please update to at least ${rel.min} to use this`)
+ console.error('a bug known to break npm. Please update to at least ' + rel.min + ' to use this')
console.error('version of npm. You can find the latest release of Node.js at https://nodejs.org/')
process.exit(1)
}