Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: raineorshine/npm-check-updates
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v16.7.6
Choose a base ref
...
head repository: raineorshine/npm-check-updates
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v16.7.7
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 22, 2023

  1. Copy the full SHA
    84ac744 View commit details
  2. 16.7.7

    raineorshine committed Feb 22, 2023
    Copy the full SHA
    3c970dc View commit details
Showing with 30 additions and 8 deletions.
  1. +2 −2 package-lock.json
  2. +1 −1 package.json
  3. +9 −5 src/lib/runLocal.ts
  4. +18 −0 test/bin.test.ts
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-check-updates",
"version": "16.7.6",
"version": "16.7.7",
"author": "Tomas Junnonen <tomas1@gmail.com>",
"license": "Apache-2.0",
"contributors": [
14 changes: 9 additions & 5 deletions src/lib/runLocal.ts
Original file line number Diff line number Diff line change
@@ -278,12 +278,16 @@ async function runLocal(
writePromise = fs.writeFile(pkgFile, newPkgData)
} else {
const ncuCmd = process.env.npm_lifecycle_event === 'npx' ? 'npx npm-check-updates' : 'ncu'
const argv = process.argv.slice(2).join(' ')
// quote arguments with spaces
const argv = process.argv
.slice(2)
.map(arg => (arg.includes(' ') ? `"${arg}"` : arg))
.join(' ')
const ncuOptions = argv ? ' ' + argv : argv
print(
options,
`\nRun ${chalk.cyan(`${ncuCmd}${ncuOptions} -u`)} to upgrade ${options.packageFile || 'package.json'}`,
)
const upgradeHint = `\nRun ${chalk.cyan(`${ncuCmd}${ncuOptions} -u`)} to upgrade ${
options.packageFile || 'package.json'
}`
print(options, upgradeHint)
}
}

18 changes: 18 additions & 0 deletions test/bin.test.ts
Original file line number Diff line number Diff line change
@@ -161,6 +161,24 @@ describe('bin', async function () {
const output = await spawn('node', [bin, '--silent'], '{ "dependencies": { "express": "1" } }')
output.trim().should.equal('')
})

it('quote arguments with spaces in upgrade hint', async () => {
const pkgData = {
dependencies: {
'ncu-test-v2': '^1.0.0',
'ncu-test-tag': '^1.0.0',
},
}
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-'))
const pkgFile = path.join(tempDir, 'package.json')
await fs.writeFile(pkgFile, JSON.stringify(pkgData), 'utf-8')
try {
const output = await spawn('node', [bin, '--packageFile', pkgFile, '--filter', 'ncu-test-v2 ncu-test-tag'])
output.should.include('"ncu-test-v2 ncu-test-tag"')
} finally {
await fs.rm(tempDir, { recursive: true, force: true })
}
})
})

describe('embedded versions', () => {