@modernpoacher/deps 2.0.19 → 2.0.20

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.
@@ -33,7 +33,8 @@ import {
33
33
  import {
34
34
  REGISTRY,
35
35
  getIgnore,
36
- getAuthor
36
+ getAuthor,
37
+ getMessage
37
38
  } from '#deps/src/common'
38
39
 
39
40
  import {
@@ -143,6 +144,28 @@ async function getAuthorFromPackage (directory) {
143
144
  )
144
145
  }
145
146
 
147
+ /**
148
+ * @function getMessageFromConfiguration
149
+ *
150
+ * Interrogates `.depsrc` or `.depsrc.json` for a `message` value
151
+ *
152
+ * @param {string} directory
153
+ * @returns {Promise<string|null>}
154
+ */
155
+ async function getMessageFromConfiguration (directory) {
156
+ log('getMessageFromConfiguration')
157
+
158
+ const CONFIGURATION = (
159
+ await hasConfiguration(directory)
160
+ ? await getConfiguration(directory)
161
+ : {}
162
+ )
163
+
164
+ return (
165
+ getMessage(CONFIGURATION)
166
+ )
167
+ }
168
+
146
169
  /**
147
170
  * @function toAuthor
148
171
  *
@@ -159,6 +182,22 @@ async function toAuthor (author, directory) {
159
182
  return author || await getAuthorFromConfiguration(directory) || await getAuthorFromPackage(directory) || AUTHOR
160
183
  }
161
184
 
185
+ /**
186
+ * @function toMessage
187
+ *
188
+ * Ensures that the `message` is set either from the command line,
189
+ * configuration, or a default
190
+ *
191
+ * Since it can be null `message` may not default in function arguments
192
+ *
193
+ * @param {string|null} message
194
+ * @param {string} directory
195
+ * @returns {Promise<string>}
196
+ */
197
+ async function toMessage (message, directory) {
198
+ return message || await getMessageFromConfiguration(directory) || MESSAGE
199
+ }
200
+
162
201
  const filterDeps = (v) => !!v // de-falsy
163
202
 
164
203
  const reduceDeps = (a, v) => a.includes(v) ? a : a.concat(v) // de-dupe
@@ -216,7 +255,7 @@ async function iterate ([directory, ...directories] = [], registry, force, messa
216
255
  if (D === await gitRevParse(D)) {
217
256
  const ignore = await getIgnoreFromConfiguration(D)
218
257
  if (!ignore) {
219
- await execute(D, registry, force, message, await toAuthor(author, D))
258
+ await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
220
259
  }
221
260
  }
222
261
  } catch (e) {
@@ -259,7 +298,7 @@ async function executeFrom (directory, registry, force, message, author) {
259
298
  const ignore = await getIgnoreFromConfiguration(D)
260
299
  if (!ignore) {
261
300
  return (
262
- await execute(D, registry, force, message, await toAuthor(author, D))
301
+ await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
263
302
  )
264
303
  }
265
304
  }
@@ -278,7 +317,7 @@ async function executeOnly (directory, registry, force, message, author) {
278
317
  const ignore = await getIgnoreFromConfiguration(D)
279
318
  if (!ignore) {
280
319
  return (
281
- await execute(D, registry, force, message, await toAuthor(author, D))
320
+ await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
282
321
  )
283
322
  }
284
323
  }
@@ -297,7 +336,7 @@ async function executePath (directory, registry, force, message, author) {
297
336
  const ignore = await getIgnoreFromConfiguration(D)
298
337
  if (!ignore) {
299
338
  return (
300
- await execute(D, registry, force, message, await toAuthor(author, D))
339
+ await execute(D, registry, force, await toMessage(message, D), await toAuthor(author, D))
301
340
  )
302
341
  }
303
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -250,9 +250,9 @@ export const getPeerDependencies = ({ peerDependencies } = {}) => peerDependenci
250
250
  /**
251
251
  * @function getIgnore
252
252
  *
253
- * Get the ignore flag by destructuring the package or configuration
253
+ * Get the ignore flag by destructuring the configuration
254
254
  *
255
- * @param {Package|Configuration}
255
+ * @param {Configuration}
256
256
  *
257
257
  * @return {boolean}
258
258
  */
@@ -287,6 +287,17 @@ export const getAuthor = ({ author = '' } = {}) => {
287
287
  return author || null
288
288
  }
289
289
 
290
+ /**
291
+ * @function getMessage
292
+ *
293
+ * Get the message by destructuring the configuration
294
+ *
295
+ * @param {Configuration}
296
+ *
297
+ * @return {string|null}
298
+ */
299
+ export const getMessage = ({ message = '' } = {}) => message || null
300
+
290
301
  /**
291
302
  * @function isPreRelease
292
303
  *