@modernpoacher/deps 2.2.39 → 2.2.40

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.
@@ -49,7 +49,7 @@ import {
49
49
  } from '#deps/src/common/env'
50
50
 
51
51
  import {
52
- toHomeDir,
52
+ formatDirectory,
53
53
  use,
54
54
  tidy
55
55
  } from '#deps/src/common/format'
@@ -241,7 +241,7 @@ async function getDepsRcJson (directory = DIRECTORY) {
241
241
  async function hasPackage (directory = DIRECTORY) {
242
242
  log('hasPackage')
243
243
 
244
- info(`Directory is "${toHomeDir(directory)}"`)
244
+ info(`Directory is "${formatDirectory(directory)}"`)
245
245
 
246
246
  try {
247
247
  await access(getPackageJsonPath(directory), constants.R_OK)
@@ -261,7 +261,7 @@ async function hasPackage (directory = DIRECTORY) {
261
261
  async function getPackage (directory = DIRECTORY) {
262
262
  log('getPackage')
263
263
 
264
- info(`Directory is "${toHomeDir(directory)}"`)
264
+ info(`Directory is "${formatDirectory(directory)}"`)
265
265
 
266
266
  try {
267
267
  return await getPackageJson(directory)
@@ -278,7 +278,7 @@ async function getPackage (directory = DIRECTORY) {
278
278
  async function hasConfiguration (directory = DIRECTORY) {
279
279
  log('hasConfiguration')
280
280
 
281
- info(`Directory is "${toHomeDir(directory)}"`)
281
+ info(`Directory is "${formatDirectory(directory)}"`)
282
282
 
283
283
  try {
284
284
  await access(getDepsRcPath(directory), constants.R_OK)
@@ -321,7 +321,7 @@ async function hasConfiguration (directory = DIRECTORY) {
321
321
  async function getConfiguration (directory = DIRECTORY) {
322
322
  log('getConfiguration')
323
323
 
324
- info(`Directory is "${toHomeDir(directory)}"`)
324
+ info(`Directory is "${formatDirectory(directory)}"`)
325
325
 
326
326
  try {
327
327
  return await getDepsRc(directory)
@@ -24,7 +24,8 @@ import {
24
24
  } from '#deps/src/common/env'
25
25
 
26
26
  import {
27
- toHomeDir
27
+ formatDirectory,
28
+ formatAuthor
28
29
  } from '#deps/src/common/format'
29
30
 
30
31
  import {
@@ -169,10 +170,10 @@ async function getAuthorFromGit (directory) {
169
170
  log('getAuthorFromGitConfig')
170
171
 
171
172
  return (
172
- getAuthor({
173
- name: await gitConfigUserName(directory),
174
- email: await gitConfigUserEmail(directory)
175
- })
173
+ formatAuthor(
174
+ await gitConfigUserName(directory) ?? '',
175
+ await gitConfigUserEmail(directory) ?? ''
176
+ )
176
177
  )
177
178
  }
178
179
 
@@ -423,7 +424,7 @@ async function execute (directory = DIRECTORY, registry = REGISTRY, force = fals
423
424
  log('execute')
424
425
 
425
426
  try {
426
- info(`Directory is "${toHomeDir(directory)}"`)
427
+ info(`Directory is "${formatDirectory(directory)}"`)
427
428
  info(`Registry is "${registry}"`)
428
429
  info(`Force is "${force}"`)
429
430
  info(`Message is "${message}"`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/deps",
3
- "version": "2.2.39",
3
+ "version": "2.2.40",
4
4
  "description": "Update NPM package dependencies from the command line",
5
5
  "keywords": [
6
6
  "deps",
@@ -54,7 +54,7 @@
54
54
  "deps-wipe": "bin/deps/wipe.sh"
55
55
  },
56
56
  "dependencies": {
57
- "@sequencemedia/write": "^0.2.15",
57
+ "@sequencemedia/write": "^0.2.16",
58
58
  "commander": "^14.0.1",
59
59
  "debug": "^4.4.3",
60
60
  "glob": "^11.0.3",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@sequencemedia/eslint-config-standard": "^0.2.89",
66
- "@sequencemedia/eslint-config-typescript": "^0.1.151",
66
+ "@sequencemedia/eslint-config-typescript": "^0.1.152",
67
67
  "@sequencemedia/eslint-merge": "^0.0.54",
68
68
  "@types/chai": "^5.2.2",
69
69
  "@types/debug": "^4.1.12",
@@ -21,7 +21,6 @@ const {
21
21
  } = JSON.parse(readFileSync(join(PATH, 'package.json')).toString('utf8'))
22
22
 
23
23
  const PLATFORM = platform()
24
-
25
24
  const HOMEDIR = homedir()
26
25
 
27
26
  const {
@@ -14,10 +14,25 @@ const log = debug('@modernpoacher/deps')
14
14
  log(`\`common/format\` (${NAME} - ${VERSION} - ${PLATFORM}) is awake`)
15
15
 
16
16
  /**
17
- * @function toHomeDir
17
+ * @function formatAuthor
18
+ * @type {(name: string, email: string) => string | null}
19
+ */
20
+ export function formatAuthor (name, email) {
21
+ const n = name.trim()
22
+ const e = email.trim()
23
+
24
+ return (
25
+ n && e
26
+ ? `${n} <${e}>`
27
+ : null
28
+ )
29
+ }
30
+
31
+ /**
32
+ * @function formatDirectory
18
33
  * @type {(directory: string) => string}
19
34
  */
20
- export const toHomeDir = PLATFORM === 'win32'
35
+ export const formatDirectory = PLATFORM === 'win32'
21
36
  ? (directory) => directory
22
37
  : (directory) => directory.includes(HOMEDIR) ? directory.replace(HOMEDIR, '~') : directory
23
38
 
@@ -20,6 +20,7 @@ import {
20
20
  } from '#deps/src/common/env'
21
21
 
22
22
  import {
23
+ formatAuthor,
23
24
  tidy
24
25
  } from '#deps/src/common/format'
25
26
 
@@ -243,24 +244,39 @@ export function getIgnore ({ ignore = false }) {
243
244
  export function getAuthor ({ author = '' }) {
244
245
  if (typeof author === 'string') return author
245
246
  if (typeof (author || false) === 'object') {
246
- const {
247
- name: NAME = '',
248
- email: EMAIL = ''
249
- } = author
250
-
251
- const name = String(NAME).trim()
252
- const email = String(EMAIL).trim()
253
-
254
247
  return (
255
- name && email
256
- ? `${name} <${email}>`
257
- : null
248
+ formatAuthor(
249
+ String(getName(author) ?? ''),
250
+ String(getEmail(author) ?? '')
251
+ )
258
252
  )
259
253
  }
260
254
 
261
255
  return null
262
256
  }
263
257
 
258
+ /**
259
+ * @function getName
260
+ * @description
261
+ * Get the name by destructuring the configuration `author`
262
+ * @param {Configuration} author
263
+ * @returns {string}
264
+ */
265
+ export function getName ({ name = '' }) {
266
+ return name
267
+ }
268
+
269
+ /**
270
+ * @function getEmail
271
+ * @description
272
+ * Get the email by destructuring the configuration `author`
273
+ * @param {Configuration} author
274
+ * @returns {string}
275
+ */
276
+ export function getEmail ({ email = '' }) {
277
+ return email
278
+ }
279
+
264
280
  /**
265
281
  * @function getMessage
266
282
  * @description
package/src/index.mjs CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  } from '#deps/src/common/env'
37
37
 
38
38
  import {
39
- toHomeDir,
39
+ formatDirectory,
40
40
  use
41
41
  } from '#deps/src/common/format'
42
42
 
@@ -251,7 +251,7 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
251
251
 
252
252
  const directory = normalize(d.trim())
253
253
 
254
- info(`Directory is "${toHomeDir(directory)}"`)
254
+ info(`Directory is "${formatDirectory(directory)}"`)
255
255
 
256
256
  return (
257
257
  new Promise((resolve, reject) => {
@@ -298,7 +298,7 @@ export function installSaveBundle (d, deps, r, f) {
298
298
 
299
299
  const directory = normalize(d.trim())
300
300
 
301
- info(`Directory is "${toHomeDir(directory)}"`)
301
+ info(`Directory is "${formatDirectory(directory)}"`)
302
302
 
303
303
  return (
304
304
  new Promise((resolve, reject) => {
@@ -345,7 +345,7 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
345
345
 
346
346
  const directory = normalize(d.trim())
347
347
 
348
- info(`Directory is "${toHomeDir(directory)}"`)
348
+ info(`Directory is "${formatDirectory(directory)}"`)
349
349
 
350
350
  return (
351
351
  new Promise((resolve, reject) => {
@@ -392,7 +392,7 @@ export function installSaveOptional (d, deps, r, f) {
392
392
 
393
393
  const directory = normalize(d.trim())
394
394
 
395
- info(`Directory is "${toHomeDir(directory)}"`)
395
+ info(`Directory is "${formatDirectory(directory)}"`)
396
396
 
397
397
  return (
398
398
  new Promise((resolve, reject) => {
@@ -439,7 +439,7 @@ export function installSaveDevSaveExact (d, deps, r, f) {
439
439
 
440
440
  const directory = normalize(d.trim())
441
441
 
442
- info(`Directory is "${toHomeDir(directory)}"`)
442
+ info(`Directory is "${formatDirectory(directory)}"`)
443
443
 
444
444
  return (
445
445
  new Promise((resolve, reject) => {
@@ -486,7 +486,7 @@ export function installSaveDev (d, deps, r, f) {
486
486
 
487
487
  const directory = normalize(d.trim())
488
488
 
489
- info(`Directory is "${toHomeDir(directory)}"`)
489
+ info(`Directory is "${formatDirectory(directory)}"`)
490
490
 
491
491
  return (
492
492
  new Promise((resolve, reject) => {
@@ -533,7 +533,7 @@ export function installSaveProdSaveExact (d, deps, r, f) {
533
533
 
534
534
  const directory = normalize(d.trim())
535
535
 
536
- info(`Directory is "${toHomeDir(directory)}"`)
536
+ info(`Directory is "${formatDirectory(directory)}"`)
537
537
 
538
538
  return (
539
539
  new Promise((resolve, reject) => {
@@ -580,7 +580,7 @@ export function installSaveProd (d, deps, r, f) {
580
580
 
581
581
  const directory = normalize(d.trim())
582
582
 
583
- info(`Directory is "${toHomeDir(directory)}"`)
583
+ info(`Directory is "${formatDirectory(directory)}"`)
584
584
 
585
585
  return (
586
586
  new Promise((resolve, reject) => {
@@ -29,7 +29,7 @@ import {
29
29
  } from '#deps/src/common/env'
30
30
 
31
31
  import {
32
- toHomeDir
32
+ formatDirectory
33
33
  } from '#deps/src/common/format'
34
34
 
35
35
  import {
@@ -107,7 +107,7 @@ export function installSaveExact (d, p, s, r, f) {
107
107
 
108
108
  const directory = normalize(d.trim())
109
109
 
110
- info(`Directory is "${toHomeDir(directory)}"`)
110
+ info(`Directory is "${formatDirectory(directory)}"`)
111
111
 
112
112
  return (
113
113
  new Promise((resolve, reject) => {
@@ -153,7 +153,7 @@ export function install (d, p, s, r, f) {
153
153
 
154
154
  const directory = normalize(d.trim())
155
155
 
156
- info(`Directory is "${toHomeDir(directory)}"`)
156
+ info(`Directory is "${formatDirectory(directory)}"`)
157
157
 
158
158
  return (
159
159
  new Promise((resolve, reject) => {