Skip to content

Commit f951820

Browse files
committed
1 parent 7a949ad commit f951820

File tree

11 files changed

+151
-49
lines changed

11 files changed

+151
-49
lines changed

node_modules/common-ancestor-path/LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Blue Oak Model License
2+
3+
Version 1.0.0
4+
5+
## Purpose
6+
7+
This license gives everyone as much permission to work with
8+
this software as possible, while protecting contributors
9+
from liability.
10+
11+
## Acceptance
12+
13+
In order to receive this license, you must agree to its
14+
rules. The rules of this license are both obligations
15+
under that agreement and conditions to your license.
16+
You must not do anything with this software that triggers
17+
a rule that you cannot or will not follow.
18+
19+
## Copyright
20+
21+
Each contributor licenses you to do everything with this
22+
software that would otherwise infringe that contributor's
23+
copyright in it.
24+
25+
## Notices
26+
27+
You must ensure that everyone who gets a copy of
28+
any part of this software from you, with or without
29+
changes, also gets the text of this license or a link to
30+
<https://blueoakcouncil.org/license/1.0.0>.
31+
32+
## Excuse
33+
34+
If anyone notifies you in writing that you have not
35+
complied with [Notices](#notices), you can keep your
36+
license by taking all practical steps to comply within 30
37+
days after the notice. If you do not do so, your license
38+
ends immediately.
39+
40+
## Patent
41+
42+
Each contributor licenses you to do everything with this
43+
software that would otherwise infringe any patent claims
44+
they can license or become able to license.
45+
46+
## Reliability
47+
48+
No contributor can revoke this license.
49+
50+
## No Liability
51+
52+
***As far as the law allows, this software comes as is,
53+
without any warranty or condition, and no contributor
54+
will be liable to anyone for any damages related to this
55+
software or this license, under any kind of legal claim.***
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.commonAncestorPath = void 0;
4+
const node_path_1 = require("node:path");
5+
function* commonArrayMembers(a, b) {
6+
const [l, s] = a.length > b.length ? [a, b] : [b, a];
7+
for (const x of s) {
8+
if (x === l.shift())
9+
yield x;
10+
else
11+
break;
12+
}
13+
}
14+
const cap = (a, b) => a === b ? a
15+
: !a || !b ? null
16+
: (0, node_path_1.parse)(a).root !== (0, node_path_1.parse)(b).root ? null
17+
: [...commonArrayMembers((0, node_path_1.normalize)(a).split(node_path_1.sep), (0, node_path_1.normalize)(b).split(node_path_1.sep))].join(node_path_1.sep);
18+
const commonAncestorPath = (...paths) => paths.reduce(cap);
19+
exports.commonAncestorPath = commonAncestorPath;
20+
//# sourceMappingURL=index.js.map
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { parse, sep, normalize as norm } from 'node:path';
2+
function* commonArrayMembers(a, b) {
3+
const [l, s] = a.length > b.length ? [a, b] : [b, a];
4+
for (const x of s) {
5+
if (x === l.shift())
6+
yield x;
7+
else
8+
break;
9+
}
10+
}
11+
const cap = (a, b) => a === b ? a
12+
: !a || !b ? null
13+
: parse(a).root !== parse(b).root ? null
14+
: [...commonArrayMembers(norm(a).split(sep), norm(b).split(sep))].join(sep);
15+
export const commonAncestorPath = (...paths) => paths.reduce(cap);
16+
//# sourceMappingURL=index.js.map
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

node_modules/common-ancestor-path/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,60 @@
11
{
22
"name": "common-ancestor-path",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"files": [
5-
"index.js"
5+
"dist"
66
],
77
"description": "Find the common ancestor of 2 or more paths on Windows or Unix",
88
"repository": {
99
"type": "git",
10-
"url": "git+https://github.com/isaacs/common-ancestor-path"
10+
"url": "git@github.com:isaacs/common-ancestor-path"
1111
},
1212
"author": "Isaac Z. Schlueter <[email protected]> (https://izs.me)",
13-
"license": "ISC",
13+
"license": "BlueOak-1.0.0",
1414
"scripts": {
15-
"test": "tap",
16-
"snap": "tap",
1715
"preversion": "npm test",
1816
"postversion": "npm publish",
19-
"prepublishOnly": "git push origin --follow-tags"
20-
},
21-
"tap": {
22-
"check-coverage": true
17+
"prepublishOnly": "git push origin --follow-tags",
18+
"prepare": "tshy",
19+
"pretest": "npm run prepare",
20+
"presnap": "npm run prepare",
21+
"test": "tap",
22+
"snap": "tap",
23+
"format": "prettier --write . --log-level warn --cache",
24+
"typedoc": "typedoc"
2325
},
2426
"devDependencies": {
27+
"@types/node": "^24.10.1",
28+
"prettier": "^3.6.2",
2529
"require-inject": "^1.4.4",
26-
"tap": "^14.10.7"
30+
"tap": "^21.1.6",
31+
"tshy": "^3.1.0",
32+
"typedoc": "^0.28.14"
33+
},
34+
"type": "module",
35+
"tshy": {
36+
"exports": {
37+
"./package.json": "./package.json",
38+
".": "./src/index.ts"
39+
}
40+
},
41+
"exports": {
42+
"./package.json": "./package.json",
43+
".": {
44+
"import": {
45+
"types": "./dist/esm/index.d.ts",
46+
"default": "./dist/esm/index.js"
47+
},
48+
"require": {
49+
"types": "./dist/commonjs/index.d.ts",
50+
"default": "./dist/commonjs/index.js"
51+
}
52+
}
53+
},
54+
"main": "./dist/commonjs/index.js",
55+
"types": "./dist/commonjs/index.d.ts",
56+
"module": "./dist/esm/index.js",
57+
"engines": {
58+
"node": ">= 18"
2759
}
2860
}

package-lock.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,8 +3595,13 @@
35953595
"license": "MIT"
35963596
},
35973597
"node_modules/common-ancestor-path": {
3598-
"version": "1.0.1",
3599-
"license": "ISC"
3598+
"version": "2.0.0",
3599+
"resolved": "https://registry.npmjs.org/common-ancestor-path/-/common-ancestor-path-2.0.0.tgz",
3600+
"integrity": "sha512-dnN3ibLeoRf2HNC+OlCiNc5d2zxbLJXOtiZUudNFSXZrNSydxcCsSpRzXwfu7BBWCIfHPw+xTayeBvJCP/D8Ng==",
3601+
"license": "BlueOak-1.0.0",
3602+
"engines": {
3603+
"node": ">= 18"
3604+
}
36003605
},
36013606
"node_modules/commondir": {
36023607
"version": "1.0.1",
@@ -14539,7 +14544,7 @@
1453914544
"@npmcli/run-script": "^10.0.0",
1454014545
"bin-links": "^6.0.0",
1454114546
"cacache": "^20.0.1",
14542-
"common-ancestor-path": "^1.0.1",
14547+
"common-ancestor-path": "^2.0.0",
1454314548
"hosted-git-info": "^9.0.0",
1454414549
"json-stringify-nice": "^1.1.4",
1454514550
"lru-cache": "^11.2.1",

workspaces/arborist/lib/arborist/load-actual.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { dirname, join, normalize, relative, resolve } = require('node:path')
55
const PackageJson = require('@npmcli/package-json')
66
const { readdirScoped } = require('@npmcli/fs')
77
const { walkUp } = require('walk-up-path')
8-
const ancestorPath = require('common-ancestor-path')
8+
const { commonAncestorPath } = require('common-ancestor-path')
99
const treeCheck = require('../tree-check.js')
1010

1111
const Shrinkwrap = require('../shrinkwrap.js')
@@ -364,7 +364,7 @@ module.exports = cls => class ActualLoader extends cls {
364364
const nmContents = new Map()
365365
const tree = this.#actualTree
366366
for (const node of tree.inventory.values()) {
367-
const ancestor = ancestorPath(node.realpath, this.path)
367+
const ancestor = commonAncestorPath(node.realpath, this.path)
368368

369369
const depPromises = []
370370
for (const [name, edge] of node.edgesOut.entries()) {

0 commit comments

Comments
 (0)