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.11.1
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.11.2
Choose a head ref
  • 5 commits
  • 9 files changed
  • 1 contributor

Commits on Aug 16, 2023

  1. Copy the full SHA
    7c38092 View commit details
  2. rc-config: Add before/after to describe block.

    Related to the workspaces test failure on Node v20 on Github Actions.
    raineorshine committed Aug 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c7a339c View commit details
  3. Copy the full SHA
    54184e0 View commit details
  4. Copy the full SHA
    0ffb0e8 View commit details
  5. 16.11.2

    raineorshine committed Aug 16, 2023
    Copy the full SHA
    144cf9d View commit details
Showing with 31 additions and 61 deletions.
  1. +1 −1 .github/workflows/test.yml
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +1 −1 src/package-managers/filters.ts
  5. +1 −1 src/package-managers/npm.ts
  6. +18 −48 test/enginesNode.test.ts
  7. +1 −2 test/helpers/stubNpmView.ts
  8. +5 −4 test/rc-config.test.ts
  9. +1 −1 test/workspaces.test.ts
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ jobs:

- name: Run tests
run: npm run test
if: "!(startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV)"
if: (!(startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV))

- name: Run tests with coverage
run: npx c8 -- npm test
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.11.1",
"version": "16.11.2",
"author": "Tomas Junnonen <tomas1@gmail.com>",
"license": "Apache-2.0",
"contributors": [
2 changes: 1 addition & 1 deletion src/package-managers/filters.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export function satisfiesNodeEngine(versionResult: Packument, nodeEngineVersion:
const minVersion = get(semver.minVersion(nodeEngineVersion), 'version')
if (!minVersion) return true
const versionNodeEngine: string | undefined = get(versionResult, 'engines.node')
return !!versionNodeEngine && semver.satisfies(minVersion, versionNodeEngine)
return !versionNodeEngine || semver.satisfies(minVersion, versionNodeEngine)
}

/**
2 changes: 1 addition & 1 deletion src/package-managers/npm.ts
Original file line number Diff line number Diff line change
@@ -388,7 +388,7 @@ async function viewMany(
}

if (npmConfigProject && Object.keys(npmConfigProject).length > 0) {
print(options, `\npm config (project: ${npmConfigProjectPath}):`, 'verbose')
print(options, `\nnpm config (project: ${npmConfigProjectPath}):`, 'verbose')
print(options, omit(npmConfigProject, 'cache'), 'verbose')
}

66 changes: 18 additions & 48 deletions test/enginesNode.test.ts
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ chai.should()
process.env.NCU_TESTS = 'true'

describe('enginesNode', () => {
it('enable --enginesNode matching ', async () => {
const upgradedPkg = await ncu({
jsonAll: true,
it("update packages that satisfy the project's engines.node", async () => {
const upgraded = await ncu({
enginesNode: true,
packageData: {
dependencies: {
del: '3.0.0',
@@ -18,74 +18,44 @@ describe('enginesNode', () => {
node: '>=6',
},
},
enginesNode: true,
})

upgradedPkg!.should.eql({
dependencies: {
del: '4.1.1',
},
engines: {
node: '>=6',
},
upgraded!.should.eql({
del: '4.1.1',
})
})

it('enable engines matching if --enginesNode', async () => {
const upgradedPkg = await ncu({
jsonAll: true,
it('do not update packages with incompatible engines.node', async () => {
const upgraded = await ncu({
enginesNode: true,
packageData: {
dependencies: {
del: '3.0.0',
},
engines: {
node: '>=6',
node: '>=1',
},
},
enginesNode: true,
})

upgradedPkg!.should.have.property('dependencies')
const deps = upgradedPkg!.dependencies as Index<VersionSpec>
deps.should.have.property('del')
deps.del.should.equal('4.1.1')
upgraded!.should.eql({})
})

it('enable engines matching if --enginesNode, not update if matches not exists', async () => {
const upgradedPkg = await ncu({
jsonAll: true,
it('update packages that do not have engines.node', async () => {
const upgraded = (await ncu({
enginesNode: true,
packageData: {
dependencies: {
del: '3.0.0',
'ncu-test-v2': '1.0.0',
},
engines: {
node: '>=1',
node: '>=6',
},
},
enginesNode: true,
})

upgradedPkg!.should.have.property('dependencies')
const deps = upgradedPkg!.dependencies as Index<VersionSpec>
deps.should.have.property('del')
deps.del.should.equal('3.0.0')
})
})) as Index<VersionSpec>

it('enable engines matching if --enginesNode, update to latest version if engines.node not exists', async () => {
const upgradedPkg = await ncu({
jsonAll: true,
packageData: {
dependencies: {
del: '3.0.0',
},
},
enginesNode: true,
upgraded!.should.eql({
'ncu-test-v2': '2.0.0',
})

upgradedPkg!.should.have.property('dependencies')
const deps = upgradedPkg!.dependencies as Index<VersionSpec>
deps.should.have.property('del')
deps.del.should.not.equal('3.0.0')
deps.del.should.not.equal('4.1.1')
})
})
3 changes: 1 addition & 2 deletions test/helpers/stubNpmView.ts
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ const stubNpmView = (mockReturnedVersions: MockedVersions, { spawn }: { spawn?:
process.env.STUB_NPM_VIEW = JSON.stringify(mockReturnedVersions)
return {
restore: () => {
// eslint-disable-next-line fp/no-delete
delete process.env.STUB_NPM_VIEW
process.env.STUB_NPM_VIEW = ''
},
}
}
9 changes: 5 additions & 4 deletions test/rc-config.test.ts
Original file line number Diff line number Diff line change
@@ -15,11 +15,12 @@ process.env.NCU_TESTS = 'true'

const bin = path.join(__dirname, '../build/src/bin/cli.js')

let stub: { restore: () => void }
before(() => (stub = stubNpmView('99.9.9', { spawn: true })))
after(() => stub.restore())

describe('rc-config', () => {
// before/after must be placed within the describe block, otherwise they will apply to tests in other files
let stub: { restore: () => void }
before(() => (stub = stubNpmView('99.9.9', { spawn: true })))
after(() => stub.restore())

it('print rcConfigPath when there is a non-empty rc config file', async () => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-'))
const tempConfigFile = path.join(tempDir, '.ncurc.json')
2 changes: 1 addition & 1 deletion test/workspaces.test.ts
Original file line number Diff line number Diff line change
@@ -429,7 +429,7 @@ describe('stubbed', () => {
})

describe('pnpm', () => {
it('read packages from pnpm-workspaces.yaml', async () => {
it('read packages from pnpm-workspace.yaml', async () => {
const tempDir = await setup(['packages/**'], { pnpm: true })
try {
const output = await spawn('node', [bin, '--jsonAll', '--workspaces'], { cwd: tempDir }).then(JSON.parse)