@nomicfoundation/hardhat-utils 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/src/path.d.ts +13 -0
- package/dist/src/path.d.ts.map +1 -1
- package/dist/src/path.js +20 -0
- package/dist/src/path.js.map +1 -1
- package/package.json +7 -6
- package/src/path.ts +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @nomicfoundation/hardhat-utils
|
|
2
2
|
|
|
3
|
+
## 4.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#8264](https://github.com/NomicFoundation/hardhat/pull/8264) [`8452f97`](https://github.com/NomicFoundation/hardhat/commit/8452f9726205540e1684d3f8458bfd145e790226) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Export `./package.json` so consumers can import the package's manifest.
|
|
8
|
+
|
|
3
9
|
## 4.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/src/path.d.ts
CHANGED
|
@@ -23,4 +23,17 @@ export declare function resolveFromRoot(root: string, target: string): string;
|
|
|
23
23
|
* @returns The shorter path, if possible, or the original path.
|
|
24
24
|
*/
|
|
25
25
|
export declare function shortenPath(absolutePath: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a version of {@link name} that is safe to use as a single filename
|
|
28
|
+
* component on POSIX, macOS, and Windows.
|
|
29
|
+
*
|
|
30
|
+
* Strips characters that are reserved on at least one of those platforms
|
|
31
|
+
* (`<>:"/\|?*` and ASCII control chars), trims trailing dots and whitespace
|
|
32
|
+
* (Windows silently strips them on write), and falls back to `_` if the
|
|
33
|
+
* result is empty or one of the path-traversal literals `.` / `..`.
|
|
34
|
+
*
|
|
35
|
+
* @param name The string to sanitize.
|
|
36
|
+
* @returns A non-empty filename-safe string.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sanitizeFilename(name: string): string;
|
|
26
39
|
//# sourceMappingURL=path.d.ts.map
|
package/dist/src/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAqBxD"}
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAqBxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASrD"}
|
package/dist/src/path.js
CHANGED
|
@@ -44,4 +44,24 @@ export function shortenPath(absolutePath) {
|
|
|
44
44
|
}
|
|
45
45
|
return absolutePath;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns a version of {@link name} that is safe to use as a single filename
|
|
49
|
+
* component on POSIX, macOS, and Windows.
|
|
50
|
+
*
|
|
51
|
+
* Strips characters that are reserved on at least one of those platforms
|
|
52
|
+
* (`<>:"/\|?*` and ASCII control chars), trims trailing dots and whitespace
|
|
53
|
+
* (Windows silently strips them on write), and falls back to `_` if the
|
|
54
|
+
* result is empty or one of the path-traversal literals `.` / `..`.
|
|
55
|
+
*
|
|
56
|
+
* @param name The string to sanitize.
|
|
57
|
+
* @returns A non-empty filename-safe string.
|
|
58
|
+
*/
|
|
59
|
+
export function sanitizeFilename(name) {
|
|
60
|
+
let result = name.replace(/[<>:"/\\|?*\x00-\x1F\x7F]/g, "");
|
|
61
|
+
result = result.replace(/[\s.]+$/, "");
|
|
62
|
+
if (result === "" || result === "." || result === "..") {
|
|
63
|
+
result = "_";
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
47
67
|
//# sourceMappingURL=path.js.map
|
package/dist/src/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,YAAoB;IAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,IAAI,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEpD,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,IACE,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;QACzC,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACxC,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAC9B,CAAC;QACD,YAAY,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC;IAC/C,CAAC;IAED,IAAI,YAAY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,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAEvC,IAAI,MAAM,KAAK,EAAE,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACvD,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/hardhat-utils",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "Utilities for Hardhat and its plugins",
|
|
5
5
|
"homepage": "https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-utils",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"./stream": "./dist/src/stream.js",
|
|
40
40
|
"./subprocess": "./dist/src/subprocess.js",
|
|
41
41
|
"./synchronization": "./dist/src/synchronization.js",
|
|
42
|
-
"./spinner": "./dist/src/spinner.js"
|
|
42
|
+
"./spinner": "./dist/src/spinner.js",
|
|
43
|
+
"./package.json": "./package.json"
|
|
43
44
|
},
|
|
44
45
|
"keywords": [
|
|
45
46
|
"ethereum",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"README.md"
|
|
55
56
|
],
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.
|
|
58
|
+
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.7",
|
|
58
59
|
"@types/bn.js": "^5.1.5",
|
|
59
60
|
"@types/node": "^22.0.0",
|
|
60
61
|
"c8": "^9.1.0",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"prettier": "3.2.5",
|
|
64
65
|
"rimraf": "^5.0.5",
|
|
65
66
|
"tsx": "^4.19.3",
|
|
66
|
-
"typescript": "~
|
|
67
|
+
"typescript": "~6.0.3"
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
70
|
"@streamparser/json-node": "^0.0.22",
|
|
@@ -75,8 +76,8 @@
|
|
|
75
76
|
"undici": "^6.16.1"
|
|
76
77
|
},
|
|
77
78
|
"scripts": {
|
|
78
|
-
"lint": "pnpm
|
|
79
|
-
"lint:fix": "pnpm
|
|
79
|
+
"lint": "pnpm eslint && pnpm prettier --check",
|
|
80
|
+
"lint:fix": "pnpm eslint --fix && pnpm prettier --write",
|
|
80
81
|
"eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
81
82
|
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
|
|
82
83
|
"test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
package/src/path.ts
CHANGED
|
@@ -53,3 +53,26 @@ export function shortenPath(absolutePath: string): string {
|
|
|
53
53
|
|
|
54
54
|
return absolutePath;
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns a version of {@link name} that is safe to use as a single filename
|
|
59
|
+
* component on POSIX, macOS, and Windows.
|
|
60
|
+
*
|
|
61
|
+
* Strips characters that are reserved on at least one of those platforms
|
|
62
|
+
* (`<>:"/\|?*` and ASCII control chars), trims trailing dots and whitespace
|
|
63
|
+
* (Windows silently strips them on write), and falls back to `_` if the
|
|
64
|
+
* result is empty or one of the path-traversal literals `.` / `..`.
|
|
65
|
+
*
|
|
66
|
+
* @param name The string to sanitize.
|
|
67
|
+
* @returns A non-empty filename-safe string.
|
|
68
|
+
*/
|
|
69
|
+
export function sanitizeFilename(name: string): string {
|
|
70
|
+
let result = name.replace(/[<>:"/\\|?*\x00-\x1F\x7F]/g, "");
|
|
71
|
+
result = result.replace(/[\s.]+$/, "");
|
|
72
|
+
|
|
73
|
+
if (result === "" || result === "." || result === "..") {
|
|
74
|
+
result = "_";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return result;
|
|
78
|
+
}
|