@modernpoacher/deps 2.1.11 → 2.1.14

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.
@@ -91,15 +91,25 @@ export function getArgs () {
91
91
  )
92
92
  }
93
93
 
94
+ function filter (v) {
95
+ const s = v.trim()
96
+
97
+ return Boolean(s)
98
+ }
99
+
94
100
  export function use (key) {
95
101
  const log = debug(`@modernpoacher/deps:${key}`)
96
102
 
97
- return function use (v) {
98
- if (v.includes(String.fromCharCode(10))) v.split(String.fromCharCode(10)).map((s) => s.trimEnd()).filter(Boolean).forEach((s) => { log(s) })
99
- else {
100
- const s = v.trim()
101
- if (s !== '') log(v.trimEnd())
102
- }
103
+ function write (v) {
104
+ const s = v.trimEnd()
105
+
106
+ log(s)
107
+ }
108
+
109
+ return function use (value) {
110
+ value.split(String.fromCharCode(10))
111
+ .filter(filter)
112
+ .forEach(write)
103
113
  }
104
114
  }
105
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.1.11",
3
+ "version": "2.1.14",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -59,43 +59,87 @@ log(`\`git\` (${VERSION} - ${PLATFORM}) is awake`)
59
59
 
60
60
  const trim = (v) => v.split(String.fromCharCode(10)).map((v) => v.trimEnd()).join(String.fromCharCode(10)).trim()
61
61
 
62
- function isFatal (s) {
62
+ function filter (v) {
63
+ const s = v.trim()
64
+
65
+ return Boolean(s)
66
+ }
67
+
68
+ export function getIsDirectory (directory) {
69
+ return function isDirectory (s) {
70
+ return directory === s
71
+ }
72
+ }
73
+
74
+ export function isFatal (s) {
63
75
  return s.toLowerCase().startsWith('fatal: not a git repository')
64
76
  }
65
77
 
66
78
  export function use (key) {
67
79
  const log = debug(`@modernpoacher/deps:${key}`)
68
80
 
69
- return function use (v) {
70
- if (v.includes(String.fromCharCode(10))) v.split(String.fromCharCode(10)).map((s) => s.trimEnd()).filter(Boolean).forEach((s) => { log(s) })
71
- else {
72
- const s = v.trim()
73
- if (s !== '') log(v.trimEnd())
74
- }
81
+ function write (v) {
82
+ const s = v.trimEnd()
83
+
84
+ log(s)
85
+ }
86
+
87
+ return function use (value) {
88
+ value.split(String.fromCharCode(10))
89
+ .filter(filter)
90
+ .forEach(write)
75
91
  }
76
92
  }
77
93
 
78
94
  export function out (key, directory) {
79
95
  const log = debug(`@modernpoacher/deps:${key}`)
80
96
 
81
- return function out (v) {
82
- if (v.includes(String.fromCharCode(10))) v.split(String.fromCharCode(10)).map((s) => s.trimEnd()).filter(Boolean).filter((s) => directory !== s).forEach((s) => { log(s) })
83
- else {
84
- const s = v.trim()
85
- if (s !== '' && directory !== s) log(v.trimEnd())
86
- }
97
+ const isDirectory = getIsDirectory(directory)
98
+
99
+ function filterOut (v) {
100
+ const s = v.trim()
101
+
102
+ return (
103
+ !isDirectory(s)
104
+ )
105
+ }
106
+
107
+ function write (v) {
108
+ const s = v.trimEnd()
109
+
110
+ log(s)
111
+ }
112
+
113
+ return function out (value) {
114
+ value.split(String.fromCharCode(10))
115
+ .filter(filter).filter(filterOut)
116
+ .forEach(write)
87
117
  }
88
118
  }
89
119
 
90
120
  export function err (key, directory) {
91
121
  const log = debug(`@modernpoacher/deps:${key}`)
92
122
 
93
- return function err (v) {
94
- if (v.includes(String.fromCharCode(10))) v.split(String.fromCharCode(10)).map((s) => s.trimEnd()).filter(Boolean).filter((s) => directory !== s).filter((s) => !isFatal(s)).forEach((s) => { log(s) })
95
- else {
96
- const s = v.trim()
97
- if (s !== '' && directory !== s && !isFatal(s)) log(v.trimEnd())
98
- }
123
+ const isDirectory = getIsDirectory(directory)
124
+
125
+ function filterErr (v) {
126
+ const s = v.trim()
127
+
128
+ return (
129
+ !isDirectory(s) && !isFatal(s)
130
+ )
131
+ }
132
+
133
+ function write (v) {
134
+ const s = v.trimEnd()
135
+
136
+ log(s)
137
+ }
138
+
139
+ return function err (value) {
140
+ value.split(String.fromCharCode(10))
141
+ .filter(filter).filter(filterErr)
142
+ .forEach(write)
99
143
  }
100
144
  }
101
145
 
package/src/index.mjs CHANGED
@@ -45,15 +45,25 @@ const log = debug('@modernpoacher/deps')
45
45
 
46
46
  log(`\`deps\` (${VERSION} - ${PLATFORM}) is awake`)
47
47
 
48
+ function filter (v) {
49
+ const s = v.trim()
50
+
51
+ return Boolean(s)
52
+ }
53
+
48
54
  export function use (key) {
49
55
  const log = debug(`@modernpoacher/deps:${key}`)
50
56
 
51
- return function use (v) {
52
- if (v.includes(String.fromCharCode(10))) v.split(String.fromCharCode(10)).map((s) => s.trimEnd()).filter(Boolean).forEach((s) => { log(s) })
53
- else {
54
- const s = v.trim()
55
- if (s !== '') log(v.trimEnd())
56
- }
57
+ function write (v) {
58
+ const s = v.trimEnd()
59
+
60
+ log(s)
61
+ }
62
+
63
+ return function use (value) {
64
+ value.split(String.fromCharCode(10))
65
+ .filter(filter)
66
+ .forEach(write)
57
67
  }
58
68
  }
59
69