@modernpoacher/deps 2.2.46 → 2.2.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.2.46",
3
+ "version": "2.2.48",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -1,5 +1,10 @@
1
1
  import stripAnsi from 'strip-ansi'
2
2
 
3
+ import {
4
+ normalize,
5
+ resolve
6
+ } from 'node:path'
7
+
3
8
  import debug from '#deps/src/common/debug'
4
9
 
5
10
  import {
@@ -31,8 +36,12 @@ export function formatAuthor (name, email) {
31
36
  * @type {(directory: string) => string}
32
37
  */
33
38
  export const formatDirectory = PLATFORM === 'win32'
34
- ? (directory) => directory
35
- : (directory) => directory.includes(HOMEDIR) ? directory.replace(HOMEDIR, '~') : directory
39
+ ? (directory) => resolve(normalize(directory)).trim()
40
+ : (directory) => {
41
+ const d = resolve(normalize(directory)).trim()
42
+ if (d.startsWith(HOMEDIR)) return d.replace(new RegExp('^' + HOMEDIR), '~')
43
+ return d
44
+ }
36
45
 
37
46
  const LF = String.fromCodePoint(10)
38
47
 
@@ -44,13 +53,21 @@ export function trim (v) {
44
53
  return (
45
54
  v
46
55
  .split(LF)
47
- .map((v) => v.trim() ? v.trimEnd() : '')
56
+ .map(mapTrim)
48
57
  .filter(Boolean)
49
58
  .join(LF)
50
59
  .trim()
51
60
  )
52
61
  }
53
62
 
63
+ /**
64
+ * @param {string} v
65
+ * @returns {string}
66
+ */
67
+ export function mapTrim (v) {
68
+ return v.trim() ? v.trimEnd() : ''
69
+ }
70
+
54
71
  /**
55
72
  * @param {string} v
56
73
  * @returns {string}