| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b8d373 commit b0393fa
41 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,62 @@ | |||
| 1 | + ## 7.2.0 (2020-12-15) | ||
| 2 | + | ||
| 3 | + ### FEATURES | ||
| 4 | + | ||
| 5 | + * [`a9c4b158c`](https://github.com/npm/cli/commit/a9c4b158c46dd0d0c8d8744a97750ffd0c30cc09) | ||
| 6 | + [#2342](https://github.com/npm/cli/issues/2342) | ||
| 7 | + allow npm rebuild to accept a path to a module | ||
| 8 | + ([@nlf](https://github.com/nlf)) | ||
| 9 | + | ||
| 10 | + ### DEPENDENCIES | ||
| 11 | + | ||
| 12 | + * [`beb371800`](https://github.com/npm/cli/commit/beb371800292140bf3882253c447168a378bc154) | ||
| 13 | + [#2334](https://github.com/npm/cli/issues/2334) | ||
| 14 | + remove unused top level dep tough-cookie | ||
| 15 | + ([@darcyclarke](https://github.com/darcyclarke)) | ||
| 16 | + * [`d45e181d1`](https://github.com/npm/cli/commit/d45e181d17dd88d82b3a97f8d9cd5fa5b6230e48) | ||
| 17 | + [#2335](https://github.com/npm/cli/issues/2335) | ||
| 18 | + `ini@2.0.0`, `@npmcli/config@1.2.7` | ||
| 19 | + ([@isaacs](https://github.com/isaacs)) | ||
| 20 | + * [`ef4b18b5a`](https://github.com/npm/cli/commit/ef4b18b5a70381b264d234817cff32eeb6848a73) | ||
| 21 | + [#2309](https://github.com/npm/cli/issues/2309) | ||
| 22 | + `@npmcli/arborist@2.0.2` | ||
| 23 | + * properly remove deps when no lockfile and package.json is present | ||
| 24 | + * [`c6c013e6e`](https://github.com/npm/cli/commit/c6c013e6ebc4fe036695db1fd491eb68f3b57c68) | ||
| 25 | + `readdir-scoped-modules@1.1.0` | ||
| 26 | + * [`a1a2134aa`](https://github.com/npm/cli/commit/a1a2134aa9a1092493db6d6c9a729ff5203f0dd4) | ||
| 27 | + remove unused sorted-object dep | ||
| 28 | + ([@nlf](https://github.com/nlf)) | ||
| 29 | + * [`85c2a2d31`](https://github.com/npm/cli/commit/85c2a2d318ae066fb2c161174f5aea97e18bc9c5) | ||
| 30 | + [#2344](https://github.com/npm/cli/issues/2344) | ||
| 31 | + remove editor dependency | ||
| 32 | + ([@nlf](https://github.com/nlf)) | ||
| 33 | + | ||
| 34 | + ### TESTING | ||
| 35 | + | ||
| 36 | + * [`3a6dd511c`](https://github.com/npm/cli/commit/3a6dd511c944c5f2699825a99bba1dde333a45ef) | ||
| 37 | + npm edit | ||
| 38 | + ([@nlf](https://github.com/nlf)) | ||
| 39 | + * [`3ba5de4e7`](https://github.com/npm/cli/commit/3ba5de4e7f6c5c0f995a29844926d6ed2833addd) | ||
| 40 | + [#2347](https://github.com/npm/cli/issues/2347) | ||
| 41 | + npm help-search | ||
| 42 | + ([@nlf](https://github.com/nlf)) | ||
| 43 | + * [`6caf19f49`](https://github.com/npm/cli/commit/6caf19f491e144be3e2a1a50f492dad48b01f361) | ||
| 44 | + [#2348](https://github.com/npm/cli/issues/2348) | ||
| 45 | + npm help | ||
| 46 | + ([@nlf](https://github.com/nlf)) | ||
| 47 | + * [`cb5847e32`](https://github.com/npm/cli/commit/cb5847e3203c52062485b5de68e4f6d29b33c361) | ||
| 48 | + [#2349](https://github.com/npm/cli/issues/2349) | ||
| 49 | + npm hook | ||
| 50 | + ([@nlf](https://github.com/nlf)) | ||
| 51 | + * [`996a2f6b1`](https://github.com/npm/cli/commit/996a2f6b130d6678998a2f6a5ec97d75534d5f66) | ||
| 52 | + [#2353](https://github.com/npm/cli/issues/2353) | ||
| 53 | + npm org | ||
| 54 | + ([@nlf](https://github.com/nlf)) | ||
| 55 | + * [`8c67c38a4`](https://github.com/npm/cli/commit/8c67c38a4f476ff5be938db6b6b3ee9ac6b44db5) | ||
| 56 | + [#2354](https://github.com/npm/cli/issues/2354) | ||
| 57 | + npm set | ||
| 58 | + ([@nlf](https://github.com/nlf)) | ||
| 59 | + | ||
| 1 | 60 | ## 7.1.2 (2020-12-11) | |
| 2 | 61 | ||
| 3 | 62 | ### DEPENDENCIES | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,7 +159,7 @@ <h3 id="description">Description</h3> | |||
| 159 | 159 | the results to only the paths to the packages named. Note that nested | |
| 160 | 160 | packages will <em>also</em> show the paths to the specified packages. For | |
| 161 | 161 | example, running <code>npm ls promzard</code> in npm’s source tree will show:</p> | |
| 162 | - <pre lang="bash"><code>npm@7.1.2 /path/to/npm | ||
| 162 | + <pre lang="bash"><code>npm@7.2.0 /path/to/npm | ||
| 163 | 163 | └─┬ init-package-json@0.0.4 | |
| 164 | 164 | └── promzard@0.1.5 | |
| 165 | 165 | </code></pre> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2> | |||
| 148 | 148 | <pre lang="bash"><code>npm <command> [args] | |
| 149 | 149 | </code></pre> | |
| 150 | 150 | <h3 id="version">Version</h3> | |
| 151 | - <p>7.1.2</p> | ||
| 151 | + <p>7.2.0</p> | ||
| 152 | 152 | <h3 id="description">Description</h3> | |
| 153 | 153 | <p>npm is the package manager for the Node JavaScript platform. It puts | |
| 154 | 154 | modules in place so that node can find them, and manages dependency | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const { promisify } = require('util') | |||
| 9 | 9 | const fs = require('fs') | |
| 10 | 10 | const readFile = promisify(fs.readFile) | |
| 11 | 11 | const writeFile = promisify(fs.writeFile) | |
| 12 | - const editor = promisify(require('editor')) | ||
| 12 | + const { spawn } = require('child_process') | ||
| 13 | 13 | const { EOL } = require('os') | |
| 14 | 14 | const ini = require('ini') | |
| 15 | 15 | ||
@@ -138,9 +138,6 @@ const del = async key => { | |||
| 138 | 138 | ||
| 139 | 139 | const edit = async () => { | |
| 140 | 140 | const { editor: e, global } = npm.flatOptions | |
| 141 | - if (!e) | ||
| 142 | - throw new Error('No `editor` config or EDITOR environment variable set') | ||
| 143 | - | ||
| 144 | 141 | const where = global ? 'global' : 'user' | |
| 145 | 142 | const file = npm.config.data.get(where).source | |
| 146 | 143 | ||
@@ -183,7 +180,15 @@ ${defData} | |||
| 183 | 180 | `.split('\n').join(EOL) | |
| 184 | 181 | await mkdirp(dirname(file)) | |
| 185 | 182 | await writeFile(file, tmpData, 'utf8') | |
| 186 | - await editor(file, { editor: e }) | ||
| 183 | + await new Promise((resolve, reject) => { | ||
| 184 | + const [bin, ...args] = e.split(/\s+/) | ||
| 185 | + const editor = spawn(bin, [...args, file], { stdio: 'inherit' }) | ||
| 186 | + editor.on('exit', (code) => { | ||
| 187 | + if (code) | ||
| 188 | + return reject(new Error(`editor process exited with code: ${code}`)) | ||
| 189 | + return resolve() | ||
| 190 | + }) | ||
| 191 | + }) | ||
| 187 | 192 | } | |
| 188 | 193 | ||
| 189 | 194 | const publicVar = k => !/^(\/\/[^:]+:)?_/.test(k) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,52 +1,36 @@ | |||
| 1 | 1 | // npm edit <pkg> | |
| 2 | 2 | // open the package folder in the $EDITOR | |
| 3 | 3 | ||
| 4 | - module.exports = edit | ||
| 5 | - edit.usage = 'npm edit <pkg>[/<subpkg>...]' | ||
| 4 | + const { resolve } = require('path') | ||
| 5 | + const fs = require('graceful-fs') | ||
| 6 | + const { spawn } = require('child_process') | ||
| 7 | + const npm = require('./npm.js') | ||
| 8 | + const usageUtil = require('./utils/usage.js') | ||
| 9 | + const splitPackageNames = require('./utils/split-package-names.js') | ||
| 6 | 10 | ||
| 7 | - edit.completion = require('./utils/completion/installed-shallow.js') | ||
| 8 | - | ||
| 9 | - var npm = require('./npm.js') | ||
| 10 | - var path = require('path') | ||
| 11 | - var fs = require('graceful-fs') | ||
| 12 | - var editor = require('editor') | ||
| 13 | - var noProgressTillDone = require('./utils/no-progress-while-running').tillDone | ||
| 11 | + const usage = usageUtil('edit', 'npm edit <pkg>[/<subpkg>...]') | ||
| 12 | + const completion = require('./utils/completion/installed-shallow.js') | ||
| 14 | 13 | ||
| 15 | 14 | function edit (args, cb) { | |
| 16 | - var p = args[0] | ||
| 17 | - if (args.length !== 1 || !p) | ||
| 18 | - return cb(edit.usage) | ||
| 19 | - var e = npm.config.get('editor') | ||
| 20 | - if (!e) { | ||
| 21 | - return cb(new Error( | ||
| 22 | - "No editor set. Set the 'editor' config, or $EDITOR environ." | ||
| 23 | - )) | ||
| 24 | - } | ||
| 25 | - p = p.split('/') | ||
| 26 | - // combine scoped parts | ||
| 27 | - .reduce(function (parts, part) { | ||
| 28 | - if (parts.length === 0) | ||
| 29 | - return [part] | ||
| 30 | - | ||
| 31 | - var lastPart = parts[parts.length - 1] | ||
| 32 | - // check if previous part is the first part of a scoped package | ||
| 33 | - if (lastPart[0] === '@' && !lastPart.includes('/')) | ||
| 34 | - parts[parts.length - 1] += '/' + part | ||
| 35 | - else | ||
| 36 | - parts.push(part) | ||
| 37 | - | ||
| 38 | - return parts | ||
| 39 | - }, []) | ||
| 40 | - .join('/node_modules/') | ||
| 41 | - .replace(/(\/node_modules)+/, '/node_modules') | ||
| 42 | - var f = path.resolve(npm.dir, p) | ||
| 43 | - fs.lstat(f, function (er) { | ||
| 44 | - if (er) | ||
| 45 | - return cb(er) | ||
| 46 | - editor(f, { editor: e }, noProgressTillDone(function (er) { | ||
| 47 | - if (er) | ||
| 48 | - return cb(er) | ||
| 49 | - npm.commands.rebuild(args, cb) | ||
| 50 | - })) | ||
| 15 | + if (args.length !== 1) | ||
| 16 | + return cb(usage) | ||
| 17 | + | ||
| 18 | + const path = splitPackageNames(args[0]) | ||
| 19 | + const dir = resolve(npm.dir, path) | ||
| 20 | + | ||
| 21 | + fs.lstat(dir, (err) => { | ||
| 22 | + if (err) | ||
| 23 | + return cb(err) | ||
| 24 | + | ||
| 25 | + const [bin, ...args] = npm.config.get('editor').split(/\s+/) | ||
| 26 | + const editor = spawn(bin, [...args, dir], { stdio: 'inherit' }) | ||
| 27 | + editor.on('exit', (code) => { | ||
| 28 | + if (code) | ||
| 29 | + return cb(new Error(`editor process exited with code: ${code}`)) | ||
| 30 | + | ||
| 31 | + npm.commands.rebuild([dir], cb) | ||
| 32 | + }) | ||
| 51 | 33 | }) | |
| 52 | 34 | } | |
| 35 | + | ||
| 36 | + module.exports = Object.assign(edit, { completion, usage }) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,11 @@ | |||
| 1 | 1 | const fs = require('fs') | |
| 2 | 2 | const path = require('path') | |
| 3 | 3 | const npm = require('./npm.js') | |
| 4 | - const glob = require('glob') | ||
| 5 | 4 | const color = require('ansicolors') | |
| 6 | 5 | const output = require('./utils/output.js') | |
| 7 | 6 | const usageUtil = require('./utils/usage.js') | |
| 8 | 7 | const { promisify } = require('util') | |
| 8 | + const glob = promisify(require('glob')) | ||
| 9 | 9 | const readFile = promisify(fs.readFile) | |
| 10 | 10 | const didYouMean = require('./utils/did-you-mean.js') | |
| 11 | 11 | const { cmdList } = require('./utils/cmd-list.js') | |
@@ -23,12 +23,17 @@ const helpSearch = async args => { | |||
| 23 | 23 | ||
| 24 | 24 | const docPath = path.resolve(__dirname, '..', 'docs/content') | |
| 25 | 25 | ||
| 26 | - // XXX: make glob return a promise and remove this wrapping | ||
| 27 | - const files = await new Promise((res, rej) => | ||
| 28 | - glob(`${docPath}/*/*.md`, (er, files) => er ? rej(er) : res(files))) | ||
| 29 | - | ||
| 26 | + const files = await glob(`${docPath}/*/*.md`) | ||
| 30 | 27 | const data = await readFiles(files) | |
| 31 | 28 | const results = await searchFiles(args, data, files) | |
| 29 | + // if only one result, then just show that help section. | ||
| 30 | + if (results.length === 1) { | ||
| 31 | + return npm.commands.help([path.basename(results[0].file, '.md')], er => { | ||
| 32 | + if (er) | ||
| 33 | + throw er | ||
| 34 | + }) | ||
| 35 | + } | ||
| 36 | + | ||
| 32 | 37 | const formatted = formatResults(args, results) | |
| 33 | 38 | if (!formatted.trim()) | |
| 34 | 39 | npmUsage(false) | |
@@ -125,15 +130,6 @@ const searchFiles = async (args, data, files) => { | |||
| 125 | 130 | }) | |
| 126 | 131 | } | |
| 127 | 132 | ||
| 128 | - // if only one result, then just show that help section. | ||
| 129 | - if (results.length === 1) { | ||
| 130 | - npm.commands.help([results[0].file.replace(/\.md$/, '')], er => { | ||
| 131 | - if (er) | ||
| 132 | - throw er | ||
| 133 | - }) | ||
| 134 | - return [] | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | 133 | // sort results by number of results found, then by number of hits | |
| 138 | 134 | // then by number of matching lines | |
| 139 | 135 | return results.sort((a, b) => | |
@@ -147,9 +143,6 @@ const searchFiles = async (args, data, files) => { | |||
| 147 | 143 | } | |
| 148 | 144 | ||
| 149 | 145 | const formatResults = (args, results) => { | |
| 150 | - if (!results) | ||
| 151 | - return 'No results for ' + args.map(JSON.stringify).join(' ') | ||
| 152 | - | ||
| 153 | 146 | const cols = Math.min(process.stdout.columns || Infinity, 80) + 1 | |
| 154 | 147 | ||
| 155 | 148 | const out = results.map(res => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,7 +133,12 @@ function viewMan (man, cb) { | |||
| 133 | 133 | break | |
| 134 | 134 | ||
| 135 | 135 | case 'browser': | |
| 136 | - openUrl(htmlMan(man), 'help available at the following URL', cb) | ||
| 136 | + try { | ||
| 137 | + var url = htmlMan(man) | ||
| 138 | + } catch (err) { | ||
| 139 | + return cb(err) | ||
| 140 | + } | ||
| 141 | + openUrl(url, 'help available at the following URL', cb) | ||
| 137 | 142 | break | |
| 138 | 143 | ||
| 139 | 144 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,9 +73,9 @@ function orgSet (org, user, role, opts) { | |||
| 73 | 73 | memDeets.org.size, | |
| 74 | 74 | memDeets.user, | |
| 75 | 75 | memDeets.role, | |
| 76 | - ]) | ||
| 76 | + ].join('\t')) | ||
| 77 | 77 | } else if (!opts.silent && opts.loglevel !== 'silent') | |
| 78 | - output(`Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now ${memDeets.org.size} member${memDeets.org.size === 1 ? '' : 's'} in this org.`) | ||
| 78 | + output(`Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${memDeets.org.size} member${memDeets.org.size === 1 ? '' : 's'} in this org.`) | ||
| 79 | 79 | ||
| 80 | 80 | return memDeets | |
| 81 | 81 | }) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,16 +39,25 @@ const getFilterFn = args => { | |||
| 39 | 39 | const spec = npa(arg) | |
| 40 | 40 | if (spec.type === 'tag' && spec.rawSpec === '') | |
| 41 | 41 | return spec | |
| 42 | - if (spec.type !== 'range' && spec.type !== 'version') | ||
| 42 | + | ||
| 43 | + if (spec.type !== 'range' && spec.type !== 'version' && spec.type !== 'directory') | ||
| 43 | 44 | throw new Error('`npm rebuild` only supports SemVer version/range specifiers') | |
| 45 | + | ||
| 44 | 46 | return spec | |
| 45 | 47 | }) | |
| 48 | + | ||
| 46 | 49 | return node => specs.some(spec => { | |
| 47 | - const { version } = node.package | ||
| 50 | + if (spec.type === 'directory') | ||
| 51 | + return node.path === spec.fetchSpec | ||
| 52 | + | ||
| 48 | 53 | if (spec.name !== node.name) | |
| 49 | 54 | return false | |
| 55 | + | ||
| 50 | 56 | if (spec.rawSpec === '' || spec.rawSpec === '*') | |
| 51 | 57 | return true | |
| 58 | + | ||
| 59 | + const { version } = node.package | ||
| 60 | + // TODO: add tests for a package with missing version | ||
| 52 | 61 | return semver.satisfies(version, spec.fetchSpec) | |
| 53 | 62 | }) | |
| 54 | 63 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments