@plugjs/plug 0.0.14 → 0.0.16

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.
Files changed (212) hide show
  1. package/dist/async.cjs +20 -19
  2. package/dist/async.cjs.map +1 -1
  3. package/dist/async.d.ts +9 -9
  4. package/dist/async.mjs +18 -17
  5. package/dist/async.mjs.map +1 -1
  6. package/dist/build.cjs +113 -110
  7. package/dist/build.cjs.map +2 -2
  8. package/dist/build.d.ts +14 -56
  9. package/dist/build.mjs +114 -111
  10. package/dist/build.mjs.map +2 -2
  11. package/dist/files.cjs +2 -16
  12. package/dist/files.cjs.map +1 -1
  13. package/dist/files.d.ts +3 -10
  14. package/dist/files.mjs +3 -17
  15. package/dist/files.mjs.map +1 -1
  16. package/dist/fork.cjs +28 -40
  17. package/dist/fork.cjs.map +1 -1
  18. package/dist/fork.d.ts +6 -27
  19. package/dist/fork.mjs +29 -40
  20. package/dist/fork.mjs.map +1 -1
  21. package/dist/helpers.cjs +27 -61
  22. package/dist/helpers.cjs.map +2 -2
  23. package/dist/helpers.d.ts +29 -31
  24. package/dist/helpers.mjs +27 -62
  25. package/dist/helpers.mjs.map +2 -2
  26. package/dist/index.cjs +15 -2
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +9 -13
  29. package/dist/index.mjs +7 -2
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/log/colors.cjs +3 -1
  32. package/dist/log/colors.cjs.map +1 -1
  33. package/dist/log/colors.d.ts +2 -2
  34. package/dist/log/colors.mjs +3 -1
  35. package/dist/log/colors.mjs.map +1 -1
  36. package/dist/log/emit.d.ts +1 -1
  37. package/dist/log/logger.cjs +4 -0
  38. package/dist/log/logger.cjs.map +1 -1
  39. package/dist/log/logger.d.ts +4 -1
  40. package/dist/log/logger.mjs +4 -0
  41. package/dist/log/logger.mjs.map +1 -1
  42. package/dist/log/options.d.ts +1 -1
  43. package/dist/log/report.cjs +2 -11
  44. package/dist/log/report.cjs.map +1 -1
  45. package/dist/log/report.d.ts +36 -4
  46. package/dist/log/report.mjs +1 -10
  47. package/dist/log/report.mjs.map +1 -1
  48. package/dist/log.cjs +1 -1
  49. package/dist/log.cjs.map +1 -1
  50. package/dist/log.d.ts +6 -6
  51. package/dist/log.mjs +2 -2
  52. package/dist/log.mjs.map +1 -1
  53. package/dist/pipe.cjs +69 -26
  54. package/dist/pipe.cjs.map +1 -1
  55. package/dist/pipe.d.ts +178 -119
  56. package/dist/pipe.mjs +71 -24
  57. package/dist/pipe.mjs.map +1 -1
  58. package/dist/plugs/copy.cjs +15 -25
  59. package/dist/plugs/copy.cjs.map +2 -2
  60. package/dist/plugs/copy.d.ts +14 -13
  61. package/dist/plugs/copy.mjs +15 -17
  62. package/dist/plugs/copy.mjs.map +2 -2
  63. package/dist/plugs/coverage/analysis.d.ts +2 -2
  64. package/dist/plugs/coverage/report.cjs +1 -1
  65. package/dist/plugs/coverage/report.cjs.map +1 -1
  66. package/dist/plugs/coverage/report.d.ts +3 -3
  67. package/dist/plugs/coverage/report.mjs +1 -1
  68. package/dist/plugs/coverage/report.mjs.map +1 -1
  69. package/dist/plugs/coverage.cjs +20 -26
  70. package/dist/plugs/coverage.cjs.map +1 -1
  71. package/dist/plugs/coverage.d.ts +33 -30
  72. package/dist/plugs/coverage.mjs +21 -19
  73. package/dist/plugs/coverage.mjs.map +1 -1
  74. package/dist/plugs/debug.cjs +12 -36
  75. package/dist/plugs/debug.cjs.map +1 -1
  76. package/dist/plugs/debug.d.ts +4 -11
  77. package/dist/plugs/debug.mjs +30 -21
  78. package/dist/plugs/debug.mjs.map +1 -1
  79. package/dist/plugs/esbuild/fix-extensions.mjs +1 -1
  80. package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
  81. package/dist/plugs/esbuild.cjs +14 -25
  82. package/dist/plugs/esbuild.cjs.map +1 -1
  83. package/dist/plugs/esbuild.d.ts +11 -16
  84. package/dist/plugs/esbuild.mjs +14 -17
  85. package/dist/plugs/esbuild.mjs.map +1 -1
  86. package/dist/plugs/eslint/runner.cjs +5 -6
  87. package/dist/plugs/eslint/runner.cjs.map +1 -1
  88. package/dist/plugs/eslint/runner.d.ts +6 -20
  89. package/dist/plugs/eslint/runner.mjs +6 -7
  90. package/dist/plugs/eslint/runner.mjs.map +1 -1
  91. package/dist/{task.cjs → plugs/eslint.cjs} +7 -24
  92. package/dist/plugs/eslint.cjs.map +6 -0
  93. package/dist/plugs/eslint.d.ts +34 -0
  94. package/dist/plugs/eslint.mjs +5 -0
  95. package/dist/plugs/eslint.mjs.map +6 -0
  96. package/dist/plugs/exec.cjs +20 -24
  97. package/dist/plugs/exec.cjs.map +1 -1
  98. package/dist/plugs/exec.d.ts +53 -53
  99. package/dist/plugs/exec.mjs +20 -23
  100. package/dist/plugs/exec.mjs.map +1 -1
  101. package/dist/plugs/filter.cjs +9 -19
  102. package/dist/plugs/filter.cjs.map +1 -1
  103. package/dist/plugs/filter.d.ts +21 -15
  104. package/dist/plugs/filter.mjs +10 -12
  105. package/dist/plugs/filter.mjs.map +1 -1
  106. package/dist/plugs/mocha/reporter.cjs +12 -6
  107. package/dist/plugs/mocha/reporter.cjs.map +1 -1
  108. package/dist/plugs/mocha/reporter.d.ts +0 -2
  109. package/dist/plugs/mocha/reporter.mjs +11 -4
  110. package/dist/plugs/mocha/reporter.mjs.map +1 -1
  111. package/dist/plugs/mocha/runner.cjs +4 -5
  112. package/dist/plugs/mocha/runner.cjs.map +1 -1
  113. package/dist/plugs/mocha/runner.d.ts +5 -31
  114. package/dist/plugs/mocha/runner.mjs +5 -6
  115. package/dist/plugs/mocha/runner.mjs.map +1 -1
  116. package/dist/plugs/mocha.cjs +22 -0
  117. package/dist/plugs/mocha.cjs.map +6 -0
  118. package/dist/plugs/mocha.d.ts +35 -0
  119. package/dist/plugs/mocha.mjs +5 -0
  120. package/dist/plugs/mocha.mjs.map +6 -0
  121. package/dist/plugs/rmf.cjs +4 -32
  122. package/dist/plugs/rmf.cjs.map +1 -1
  123. package/dist/plugs/rmf.d.ts +8 -12
  124. package/dist/plugs/rmf.mjs +25 -20
  125. package/dist/plugs/rmf.mjs.map +1 -1
  126. package/dist/plugs/tsc/compiler.d.ts +1 -1
  127. package/dist/plugs/tsc/options.d.ts +1 -1
  128. package/dist/plugs/tsc/report.d.ts +2 -2
  129. package/dist/plugs/tsc/runner.cjs +12 -11
  130. package/dist/plugs/tsc/runner.cjs.map +1 -1
  131. package/dist/plugs/tsc/runner.d.ts +4 -9
  132. package/dist/plugs/tsc/runner.mjs +12 -11
  133. package/dist/plugs/tsc/runner.mjs.map +1 -1
  134. package/dist/plugs/tsc.cjs +7 -0
  135. package/dist/plugs/tsc.cjs.map +6 -0
  136. package/dist/plugs/tsc.d.ts +36 -0
  137. package/dist/plugs/tsc.mjs +15 -0
  138. package/dist/plugs/tsc.mjs.map +6 -0
  139. package/dist/plugs.cjs +3 -5
  140. package/dist/plugs.cjs.map +1 -1
  141. package/dist/plugs.d.ts +10 -17
  142. package/dist/plugs.mjs +3 -5
  143. package/dist/plugs.mjs.map +1 -1
  144. package/dist/types.cjs +19 -0
  145. package/dist/types.cjs.map +6 -0
  146. package/dist/types.d.ts +71 -0
  147. package/dist/types.mjs +1 -0
  148. package/dist/types.mjs.map +6 -0
  149. package/dist/utils/caller.cjs +8 -11
  150. package/dist/utils/caller.cjs.map +2 -2
  151. package/dist/utils/caller.d.ts +2 -7
  152. package/dist/utils/caller.mjs +8 -11
  153. package/dist/utils/caller.mjs.map +2 -2
  154. package/dist/utils/options.cjs +4 -6
  155. package/dist/utils/options.cjs.map +1 -1
  156. package/dist/utils/options.d.ts +16 -15
  157. package/dist/utils/options.mjs +4 -6
  158. package/dist/utils/options.mjs.map +1 -1
  159. package/dist/utils/walk.d.ts +2 -2
  160. package/extra/cli.mjs +31 -20
  161. package/extra/ts-loader.mjs +6 -5
  162. package/package.json +8 -9
  163. package/src/async.ts +27 -19
  164. package/src/files.ts +6 -30
  165. package/src/fork.ts +35 -76
  166. package/src/helpers.ts +66 -99
  167. package/src/index.ts +10 -15
  168. package/src/log/colors.ts +4 -3
  169. package/src/log/emit.ts +4 -4
  170. package/src/log/logger.ts +12 -4
  171. package/src/log/options.ts +1 -1
  172. package/src/log/report.ts +8 -22
  173. package/src/log/spinner.ts +3 -3
  174. package/src/log.ts +9 -9
  175. package/src/paths.ts +1 -1
  176. package/src/pipe.ts +255 -170
  177. package/src/plugs/copy.ts +40 -31
  178. package/src/plugs/coverage/analysis.ts +4 -4
  179. package/src/plugs/coverage/report.ts +6 -5
  180. package/src/plugs/coverage.ts +64 -53
  181. package/src/plugs/debug.ts +28 -26
  182. package/src/plugs/esbuild/fix-extensions.ts +2 -2
  183. package/src/plugs/esbuild.ts +42 -46
  184. package/src/plugs/eslint/runner.ts +16 -31
  185. package/src/plugs/eslint.ts +42 -0
  186. package/src/plugs/exec.ts +93 -82
  187. package/src/plugs/filter.ts +42 -27
  188. package/src/plugs/mocha/reporter.ts +10 -5
  189. package/src/plugs/mocha/runner.ts +12 -38
  190. package/src/plugs/mocha.ts +41 -0
  191. package/src/plugs/rmf.ts +21 -25
  192. package/src/plugs/tsc/compiler.ts +1 -1
  193. package/src/plugs/tsc/options.ts +2 -2
  194. package/src/plugs/tsc/report.ts +2 -2
  195. package/src/plugs/tsc/runner.ts +24 -30
  196. package/src/plugs/tsc.ts +45 -0
  197. package/src/plugs.ts +10 -25
  198. package/src/types.ts +116 -0
  199. package/src/utils/caller.ts +11 -22
  200. package/src/utils/options.ts +49 -17
  201. package/src/utils/walk.ts +4 -4
  202. package/dist/run.cjs +0 -90
  203. package/dist/run.cjs.map +0 -6
  204. package/dist/run.d.ts +0 -89
  205. package/dist/run.mjs +0 -65
  206. package/dist/run.mjs.map +0 -6
  207. package/dist/task.cjs.map +0 -6
  208. package/dist/task.d.ts +0 -15
  209. package/dist/task.mjs +0 -14
  210. package/dist/task.mjs.map +0 -6
  211. package/src/run.ts +0 -159
  212. package/src/task.ts +0 -26
package/src/helpers.ts CHANGED
@@ -1,32 +1,61 @@
1
- import {
2
- AbsolutePath,
3
- commonPath,
4
- getCurrentWorkingDirectory,
5
- resolveDirectory,
6
- resolveFile,
7
- } from './paths.js'
1
+ import { assert } from './assert'
2
+ import { requireContext } from './async'
3
+ import { Files } from './files'
4
+ import { $p, log } from './log'
5
+ import { AbsolutePath, getCurrentWorkingDirectory, resolveDirectory, resolveFile } from './paths'
6
+ import { Pipe } from './pipe'
7
+ import { rm } from './utils/asyncfs'
8
+ import { ParseOptions, parseOptions } from './utils/options'
9
+ import { walk, WalkOptions } from './utils/walk'
10
+
11
+ /* ========================================================================== *
12
+ * EXTERNAL HELPERS *
13
+ * ========================================================================== */
14
+
15
+ /** The {@link FindOptions} interface defines the options for finding files. */
16
+ export interface FindOptions extends WalkOptions {
17
+ /** The directory where to start looking for files. */
18
+ directory?: string
19
+ }
8
20
 
9
- import { assert } from './assert.js'
10
- import { currentRun } from './async.js'
11
- import { Files, FilesBuilder } from './files.js'
12
- import { $p, log, LogLevelString } from './log.js'
13
- import { Pipe } from './pipe.js'
14
- import { FindOptions } from './run.js'
15
- import { rm } from './utils/asyncfs.js'
16
- import { ParseOptions } from './utils/options.js'
21
+ /** Find files in the current directory using the specified _glob_. */
22
+ export function find(glob: string): Pipe
23
+ /** Find files in the current directory using the specified _globs_. */
24
+ export function find(glob: string, ...globs: string[]): Pipe
25
+ /** Find files using the specified _glob_ and {@link FindOptions | options}. */
26
+ export function find(glob: string, options: FindOptions): Pipe
27
+ /** Find files using the specified _globs_ and {@link FindOptions | options}. */
28
+ export function find(glob: string, ...extra: [...globs: string[], options: FindOptions]): Pipe
29
+ /* Overload */
30
+ export function find(...args: ParseOptions<FindOptions>): Pipe {
31
+ const { params: globs, options } = parseOptions(args, {})
32
+
33
+ const context = requireContext()
34
+ return new Pipe(context, async (): Promise<Files> => {
35
+ const directory = options.directory ?
36
+ context.resolve(options.directory) :
37
+ getCurrentWorkingDirectory()
38
+
39
+ const builder = Files.builder(directory)
40
+ for await (const file of walk(directory, globs, options)) {
41
+ builder.add(file)
42
+ }
43
+
44
+ return builder.build()
45
+ })
46
+ }
17
47
 
18
48
  /**
19
49
  * Recursively remove the specified directory _**(use with care)**_.
20
50
  */
21
51
  export async function rmrf(directory: string): Promise<void> {
22
- const run = currentRun()
23
- assert(run, 'Unable to find files outside a running task')
24
- const dir = run.resolve(directory)
52
+ const context = requireContext()
53
+ const dir = context.resolve(directory)
25
54
 
26
55
  assert(dir !== getCurrentWorkingDirectory(),
27
56
  `Cowardly refusing to wipe current working directory ${$p(dir)}`)
28
57
 
29
- assert(dir !== run.buildDir,
58
+ assert(dir !== context.resolve('@'),
30
59
  `Cowardly refusing to wipe build file directory ${$p(dir)}`)
31
60
 
32
61
  if (! resolveDirectory(dir)) {
@@ -39,95 +68,33 @@ export async function rmrf(directory: string): Promise<void> {
39
68
  }
40
69
 
41
70
  /**
42
- * Set the current _log level_.
71
+ * Resolve a (set of) path(s) into an {@link AbsolutePath}.
43
72
  *
44
- * The _level_ will be applied _only_ within the execution of the current task.
73
+ * If the path (or first component thereof) starts with `@...`, then the
74
+ * resolved path will be relative to the directory containing the build file
75
+ * where the current task was defined, otherwise it will be relative to the
76
+ * current working directory.
45
77
  */
46
- export function setLogLevel(level: LogLevelString): void {
47
- const run = currentRun()
48
- assert(run, 'Unable to find files outside a running task')
49
- return run.setLogLevel(level)
78
+ export function resolve(...paths: [ string, ...string[] ]): AbsolutePath {
79
+ return requireContext().resolve(...paths)
50
80
  }
51
81
 
52
82
  /**
53
- * Resolve a path into an {@link AbsolutePath}.
83
+ * Return an absolute path of the file if it exist on disk.
54
84
  *
55
- * If the path starts with `@...` it is considered to be relative to the
56
- * _directory containing the build file where the task was defined_, otherwise
57
- * it will be relative to the {@link process.cwd | current working directory}.
58
- */
59
- export function resolve(...paths: string[]): AbsolutePath {
60
- const run = currentRun()
61
- assert(run, 'Unable to find files outside a running task')
62
- return run.resolve(...paths)
63
- }
64
-
65
-
66
- /**
67
- * Create a new {@link Files} instance.
85
+ * See the comments on {@link resolve} to understand how paths are resolved.
68
86
  */
69
- export function files(files: Files): FilesBuilder
70
- export function files(directory: string, ...paths: string[]): FilesBuilder
71
- export function files(first: Files | string | undefined, ...paths: string[]): FilesBuilder {
72
- const run = currentRun()
73
- assert(run, 'Unable to create files builder outside a running task')
74
- if (typeof first === 'string') {
75
- return run.files(first, ...paths)
76
- } else if (first) {
77
- return run.files(first)
78
- } else {
79
- return run.files()
80
- }
87
+ export function isFile(...paths: [ string, ...string[] ]): AbsolutePath | undefined {
88
+ const path = requireContext().resolve(...paths)
89
+ return resolveFile(path)
81
90
  }
82
91
 
83
92
  /**
84
- * Merge multiple {@link Files} instance.
85
- */
86
- export function merge(args: (Files | Promise<Files>)[]): Promise<Files> & Pipe {
87
- const run = currentRun()
88
- assert(run, 'Unable to create files builder outside a running task')
89
-
90
- const promise = Promise.resolve().then(async () => {
91
- // No arguments, no files... Just convenience!
92
- if (args.length === 0) return run.pipe(run.files().build())
93
-
94
- // Resolve all the `Files` instances (might be from other tasks)
95
- const instances = await Promise.all(args)
96
- const [ first, ...others ] = instances
97
-
98
- const firstDir = first.directory
99
- const otherDirs = others.map((f) => f.directory)
100
-
101
- const directory = commonPath(firstDir, ...otherDirs)
102
-
103
- return run.files(directory).merge(first, ...others).build()
104
- })
105
-
106
- return run.pipe(promise)
107
- }
108
-
109
- /**
110
- * Find files according to the globs and {@link FindOptions} specified.
93
+ * Return an absolute path of the directory if it exist on disk.
94
+ *
95
+ * See the comments on {@link resolve} to understand how paths are resolved.
111
96
  */
112
- export function find(glob: string, ...args: ParseOptions<FindOptions>): Pipe & Promise<Files> {
113
- const run = currentRun()
114
- assert(run, 'Unable to find files outside a running task')
115
- return run.find(glob, ...args)
116
- }
117
-
118
- /** Create a {@link Pipe} from a {@link Files} instance. */
119
- export function pipe(files: Files | Promise<Files>): Pipe & Promise<Files> {
120
- const run = currentRun()
121
- assert(run, 'Unable to create pipes outside a running task')
122
- return run.pipe(files)
123
- }
124
-
125
- /** Return an absolute path of the file if it exist on disk */
126
- export function isFile(...paths: string[]): AbsolutePath | undefined {
127
- return resolveFile(resolve(...paths))
128
- }
129
-
130
- /** Return an absolute path of the file if it exist on disk */
131
- export function isDirectory(...paths: string[]): AbsolutePath | undefined {
132
- return resolveDirectory(resolve(...paths))
97
+ export function isDirectory(...paths: [ string, ...string[] ]): AbsolutePath | undefined {
98
+ const path = requireContext().resolve(...paths)
99
+ return resolveDirectory(path)
133
100
  }
package/src/index.ts CHANGED
@@ -1,20 +1,15 @@
1
1
  /// <reference path="../extra/webassembly.d.ts" />
2
2
 
3
- // Our minimal exports
4
- export * from './assert.js'
5
- export * from './build.js'
6
- export * from './plugs.js'
7
- export * from './log.js'
8
- export * from './helpers.js'
3
+ export type { AbsolutePath } from './paths'
4
+ export type { Files, FilesBuilder } from './files'
5
+ export { Pipe } from './pipe'
9
6
 
10
- // Utility types
11
- export type { MatchOptions, MatchResult } from './utils/match.js'
12
- export type { ParseOptions } from './utils/options.js'
13
- export type { WalkOptions } from './utils/walk.js'
7
+ // Our minimal exports
8
+ export * from './assert'
9
+ export * from './build'
10
+ export * from './helpers'
11
+ export * from './log'
14
12
 
15
13
  // PlugJS types
16
- export type { AbsolutePath } from './paths.js'
17
- export type { Files, FilesBuilder } from './files.js'
18
- export type { FindOptions, Run } from './run.js'
19
- export type { Pipe, Plug, PlugFunction } from './pipe.js'
20
- export type { Task } from './task.js'
14
+ export * from './plugs'
15
+ export * from './types'
package/src/log/colors.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { sep } from 'node:path'
2
- import { AbsolutePath, getCurrentWorkingDirectory, resolveRelativeChildPath } from '../paths.js'
3
- import { logOptions } from './options.js'
2
+ import { AbsolutePath, getCurrentWorkingDirectory, resolveRelativeChildPath } from '../paths'
3
+ import { logOptions } from './options'
4
4
 
5
5
  /* ========================================================================== */
6
6
 
@@ -49,7 +49,7 @@ export function $t(task: string): string {
49
49
  }
50
50
 
51
51
  /** Colorize milliseconds. */
52
- export function $ms(millis: number): string {
52
+ export function $ms(millis: number, note?: string): string {
53
53
  let string: string
54
54
  if (millis >= 60000) {
55
55
  // One minute or more: style is Xm Ys
@@ -70,6 +70,7 @@ export function $ms(millis: number): string {
70
70
  // Milliseconds: style is 123ms
71
71
  string = `${millis}ms`
72
72
  }
73
+ if (note) string = `${note} ${string}`
73
74
  return _colors ? `${gry}[${string}]${rst}` : `[${string}]`
74
75
  }
75
76
 
package/src/log/emit.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { formatWithOptions } from 'node:util'
2
- import { $blu, $grn, $gry, $red, $t, $ylw } from './colors.js'
3
- import { DEBUG, INFO, LogLevel, NOTICE, TRACE, WARN } from './levels.js'
4
- import { logOptions } from './options.js'
5
- import { zapSpinner } from './spinner.js'
2
+ import { $blu, $grn, $gry, $red, $t, $ylw } from './colors'
3
+ import { DEBUG, INFO, LogLevel, NOTICE, TRACE, WARN } from './levels'
4
+ import { logOptions } from './options'
5
+ import { zapSpinner } from './spinner'
6
6
 
7
7
  /* ========================================================================== */
8
8
 
package/src/log/logger.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { isBuildError, isBuildFailure } from '../assert.js'
2
- import { emitColor, emitPlain, LogEmitter } from './emit.js'
3
- import { DEBUG, ERROR, INFO, LogLevel, NOTICE, TRACE, WARN } from './levels.js'
4
- import { logOptions } from './options.js'
1
+ import { isBuildError, isBuildFailure } from '../assert'
2
+ import { emitColor, emitPlain, LogEmitter } from './emit'
3
+ import { DEBUG, ERROR, INFO, LogLevel, NOTICE, TRACE, WARN } from './levels'
4
+ import { logOptions } from './options'
5
+ import { Report, ReportImpl } from './report'
5
6
 
6
7
  /* ========================================================================== */
7
8
 
@@ -48,6 +49,8 @@ export interface Logger extends Log {
48
49
  leave(): this
49
50
  /** Leave a sub-level of logging, decreasing indent */
50
51
  leave(level: LogLevel, message: string): this
52
+ /** Create a {@link Report} associated with this instance */
53
+ report(title: string): Report
51
54
  }
52
55
 
53
56
  /** Return a {@link Logger} associated with the specified task name. */
@@ -149,6 +152,7 @@ class LoggerImpl implements Logger {
149
152
  const [ level, message ] = args
150
153
  this._stack.push({ level, message, indent: this._indent })
151
154
  }
155
+
152
156
  this._indent ++
153
157
  return this
154
158
  }
@@ -168,4 +172,8 @@ class LoggerImpl implements Logger {
168
172
 
169
173
  return this
170
174
  }
175
+
176
+ report(title: string): Report {
177
+ return new ReportImpl(title, this._task, this._emitter)
178
+ }
171
179
  }
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'node:events'
2
2
  import { Writable } from 'node:stream'
3
3
  import { InspectOptions } from 'node:util'
4
- import { getLevelNumber, LogLevel, LogLevelString, NOTICE } from './levels.js'
4
+ import { getLevelNumber, LogLevel, LogLevelString, NOTICE } from './levels'
5
5
 
6
6
  /* ========================================================================== */
7
7
 
package/src/log/report.ts CHANGED
@@ -1,21 +1,13 @@
1
- import { fail, failure } from '../assert.js'
2
- import { AbsolutePath } from '../paths.js'
3
- import { readFile } from '../utils/asyncfs.js'
4
- import { $blu, $cyn, $gry, $red, $und, $wht, $ylw } from './colors.js'
5
- import { emitColor, emitPlain, LogEmitter } from './emit.js'
6
- import { ERROR, LogLevels, NOTICE, WARN } from './levels.js'
7
- import { logOptions } from './options.js'
1
+ import { fail, failure } from '../assert'
2
+ import { AbsolutePath } from '../paths'
3
+ import { readFile } from '../utils/asyncfs'
4
+ import { $blu, $cyn, $gry, $red, $und, $wht, $ylw } from './colors'
5
+ import { LogEmitter } from './emit'
6
+ import { ERROR, LogLevels, NOTICE, WARN } from './levels'
7
+ import { logOptions } from './options'
8
8
 
9
9
  /* ========================================================================== */
10
10
 
11
- /* Track changes for colors */
12
- let _colors = logOptions.colors
13
- logOptions.on('changed', ({ colors }) => {
14
- _colors = colors
15
- })
16
-
17
- /* ========================================================================== *
18
-
19
11
  /** Levels used in a {@link Report} */
20
12
  export type ReportLevel = LogLevels['NOTICE' | 'WARN' | 'ERROR']
21
13
 
@@ -91,12 +83,6 @@ export interface Report {
91
83
  done(showSources?: boolean | undefined): void
92
84
  }
93
85
 
94
- /** Create a new {@link Report} with the given title */
95
- export function createReport(title: string, taskName: string): Report {
96
- const emitter = _colors ? emitColor : emitPlain
97
- return new ReportImpl(title, taskName, emitter)
98
- }
99
-
100
86
  /* ========================================================================== *
101
87
  * REPORT IMPLEMENTATION *
102
88
  * ========================================================================== */
@@ -118,7 +104,7 @@ interface ReportInternalAnnotation {
118
104
  readonly note: string
119
105
  }
120
106
 
121
- class ReportImpl implements Report {
107
+ export class ReportImpl implements Report {
122
108
  private readonly _sources = new Map<AbsolutePath, string[]>()
123
109
  private readonly _annotations = new Map<AbsolutePath, ReportInternalAnnotation>()
124
110
  private readonly _records = new Map<AbsolutePath | Null, Set<ReportInternalRecord>>()
@@ -1,6 +1,6 @@
1
- import { runningTasks } from '../async.js'
2
- import { $cyn, $gry, $t } from './colors.js'
3
- import { logOptions } from './options.js'
1
+ import { runningTasks } from '../async'
2
+ import { $cyn, $gry, $t } from './colors'
3
+ import { logOptions } from './options'
4
4
 
5
5
  /* ========================================================================== */
6
6
 
package/src/log.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { currentRun } from './async.js'
2
- import { getLogger, Log } from './log/logger.js'
3
- import { setupSpinner } from './log/spinner.js'
1
+ import { currentContext } from './async'
2
+ import { getLogger, Log } from './log/logger'
3
+ import { setupSpinner } from './log/spinner'
4
4
 
5
- export * from './log/colors.js'
6
- export * from './log/levels.js'
7
- export * from './log/logger.js'
8
- export * from './log/options.js'
9
- export * from './log/report.js'
5
+ export * from './log/colors'
6
+ export * from './log/levels'
7
+ export * from './log/logger'
8
+ export * from './log/options'
9
+ export * from './log/report'
10
10
 
11
11
  /* ========================================================================== *
12
12
  * INITIALIZATION *
@@ -25,7 +25,7 @@ export type LogFunction = ((...args: [ any, ...any ]) => void) & Log
25
25
  /** Our logging function (defaulting to the `NOTICE` level) */
26
26
  export const log: LogFunction = ((): LogFunction => {
27
27
  /* Return either the current run's log, or the default task's logger */
28
- const logger = (): Log => (currentRun()?.log || getLogger())
28
+ const logger = (): Log => (currentContext()?.log || getLogger())
29
29
 
30
30
  /* Create a Logger wrapping the current logger */
31
31
  const wrapper: Log = {
package/src/paths.ts CHANGED
@@ -2,7 +2,7 @@ import { statSync } from 'node:fs'
2
2
  import { createRequire } from 'node:module'
3
3
  import { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path'
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url'
5
- import { assert } from './assert.js'
5
+ import { assert } from './assert'
6
6
 
7
7
  /** A _branded_ `string` representing an _absolute_ path name */
8
8
  export type AbsolutePath = string & { __brand_absolute_path: never }