A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/8b7bb12617e80f3e5061c96d06dd723331fffa2d below:

Allow downgrades to hoisted version dedupe workspace i… · npm/cli@8b7bb12 · GitHub

@@ -3427,3 +3427,83 @@ t.test('install stategy linked', async (t) => {

3427 3427

t.ok(abbrev.isSymbolicLink(), 'abbrev got installed')

3428 3428

})

3429 3429

})

3430 + 3431 +

t.test('workspace installs retain existing versions with newer package specs', async t => {

3432 +

const path = t.testdir({

3433 +

'package.json': JSON.stringify({

3434 +

workspaces: [

3435 +

'packages/*',

3436 +

],

3437 +

overrides: {

3438 +

'doesnt-matter-can-be-anything': '1.2.3',

3439 +

},

3440 +

}),

3441 +

packages: {

3442 +

'my-cool-package': {

3443 +

'package.json': JSON.stringify({}),

3444 +

},

3445 +

'another-cool-package': {

3446 +

'package.json': JSON.stringify({}),

3447 +

},

3448 +

},

3449 +

})

3450 + 3451 +

createRegistry(t, true)

3452 + 3453 +

// Step 1: Install abbrev@1.0.4 in my-cool-package

3454 +

await reify(path, {

3455 +

add: ['abbrev@1.0.4'],

3456 +

// setting savePrefix to '' is exactly what the --save-exact flag does in definitions.js

3457 +

savePrefix: '',

3458 +

workspaces: ['my-cool-package'],

3459 +

})

3460 + 3461 +

// Verify hoisted installation

3462 +

const rootNodeModules = resolve(path, 'node_modules/abbrev/package.json')

3463 +

t.ok(fs.existsSync(rootNodeModules), 'abbrev should be hoisted to root node_modules')

3464 + 3465 +

const hoistedPkg = JSON.parse(fs.readFileSync(rootNodeModules, 'utf8'))

3466 +

t.equal(hoistedPkg.version, '1.0.4', 'hoisted version should be 1.0.4')

3467 + 3468 +

// Check my-cool-package package.json

3469 +

const myPackageJson = JSON.parse(fs.readFileSync(

3470 +

resolve(path, 'packages/my-cool-package/package.json'), 'utf8'))

3471 +

t.same(myPackageJson.dependencies, { abbrev: '1.0.4' },

3472 +

'my-cool-package should have abbrev@1.0.4 in dependencies')

3473 + 3474 +

// Step 2: Install abbrev@1.1.1 in another-cool-package

3475 +

await reify(path, {

3476 +

add: ['abbrev@1.1.1'],

3477 +

savePrefix: '',

3478 +

workspaces: ['another-cool-package'],

3479 +

})

3480 + 3481 +

// Verify un-hoisted installation

3482 +

const anotherNodeModules = resolve(path, 'packages/another-cool-package/node_modules/abbrev/package.json')

3483 +

t.ok(fs.existsSync(anotherNodeModules), 'abbrev@1.1.1 should be installed in another-cool-package/node_modules')

3484 + 3485 +

const unhoistedPkg = JSON.parse(fs.readFileSync(anotherNodeModules, 'utf8'))

3486 +

t.equal(unhoistedPkg.version, '1.1.1', 'unhoisted version should be 1.1.1')

3487 + 3488 +

// Check another-cool-package package.json

3489 +

const anotherPackageJson = JSON.parse(fs.readFileSync(

3490 +

resolve(path, 'packages/another-cool-package/package.json'), 'utf8'))

3491 +

t.same(anotherPackageJson.dependencies, { abbrev: '1.1.1' },

3492 +

'another-cool-package should have abbrev@1.1.1 in dependencies')

3493 + 3494 +

// Step 3: Install abbrev@1.0.4 in another-cool-package

3495 +

await reify(path, {

3496 +

add: ['abbrev@1.0.4'],

3497 +

savePrefix: '',

3498 +

workspaces: ['another-cool-package'],

3499 +

})

3500 + 3501 +

t.ok(fs.existsSync(rootNodeModules), 'abbrev@1.0.4 should still be hoisted to root node_modules')

3502 +

t.notOk(fs.existsSync(anotherNodeModules), 'abbrev@1.1.1 should be removed from another-cool-package/node_modules')

3503 + 3504 +

// Check another-cool-package package.json - should now be updated to 1.0.4

3505 +

const updatedPackageJson = JSON.parse(fs.readFileSync(

3506 +

resolve(path, 'packages/another-cool-package/package.json'), 'utf8'))

3507 +

t.same(updatedPackageJson.dependencies, { abbrev: '1.0.4' },

3508 +

'another-cool-package package.json should be updated to abbrev@1.0.4')

3509 +

})


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4