js-build-tools 6.6.0 → 6.8.0

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 (173) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +768 -701
  3. package/babel.config.js +28 -28
  4. package/dist/build.js +75 -75
  5. package/dist/bundle.js +19 -19
  6. package/dist/bundleMinify.js +7 -7
  7. package/dist/compileReadme.js +4 -4
  8. package/dist/copyFiles.js +17 -17
  9. package/dist/copyFonts.js +4 -4
  10. package/dist/default.js +5 -5
  11. package/dist/dist.js +4 -4
  12. package/dist/distMinify.js +4 -4
  13. package/dist/docs.js +7 -7
  14. package/dist/images.js +4 -4
  15. package/dist/jsdocDocs.js +6 -6
  16. package/dist/lint.js +16 -16
  17. package/dist/partials/addToReadme.js +9 -9
  18. package/dist/partials/beginWatcher.js +4 -4
  19. package/dist/partials/cacheFiles.js +121 -0
  20. package/dist/partials/clean.js +5 -5
  21. package/dist/partials/copyFor.js +9 -9
  22. package/dist/partials/distFor.js +6 -6
  23. package/dist/partials/distForSrc.js +5 -5
  24. package/dist/partials/distSeries.js +7 -7
  25. package/dist/partials/imagesFor.js +155 -93
  26. package/dist/partials/jsdocDocsFor.js +64 -51
  27. package/dist/partials/lintSource.js +51 -51
  28. package/dist/partials/loadPeer.js +99 -99
  29. package/dist/partials/loadPlaywright.js +14 -14
  30. package/dist/partials/minifyFor.js +20 -20
  31. package/dist/partials/neostandardLint.js +175 -175
  32. package/dist/partials/readmeTemplate.js +4 -4
  33. package/dist/partials/removeDirectory.js +11 -11
  34. package/dist/partials/resolveDocsMethod.js +6 -6
  35. package/dist/partials/runOnChange.js +31 -31
  36. package/dist/partials/sassFor.js +6 -6
  37. package/dist/partials/serveStatic.js +9 -9
  38. package/dist/partials/tsFor.js +32 -32
  39. package/dist/partials/typeDocsFor.js +264 -264
  40. package/dist/partials.js +183 -176
  41. package/dist/partials.min.js +1 -1
  42. package/dist/sourceLint.js +18 -18
  43. package/dist/test-helpers/setUp.js +6 -4
  44. package/dist/testFull.js +5 -5
  45. package/dist/testQuick.js +5 -5
  46. package/dist/typeDocs.js +5 -5
  47. package/dist/typeScript.js +4 -4
  48. package/dist/utilities/convertMjsFilesForDocs.js +12 -12
  49. package/dist/utilities/dotGet.js +54 -54
  50. package/dist/utilities/dotNotate.js +79 -79
  51. package/dist/utilities/dotSet.js +45 -45
  52. package/dist/utilities/esmNamedExportsToCjs.js +15 -15
  53. package/dist/utilities/getBundleConfigs.js +9 -9
  54. package/dist/utilities/isObject.js +6 -6
  55. package/dist/utilities/strAfter.js +7 -7
  56. package/dist/utilities/strBefore.js +7 -7
  57. package/dist/watchFull.js +4 -4
  58. package/dist/watchTest.js +4 -4
  59. package/functions/build.mjs +72 -72
  60. package/functions/build.test.mjs +760 -759
  61. package/functions/bundle.mjs +44 -44
  62. package/functions/bundle.test.mjs +219 -219
  63. package/functions/bundleMinify.mjs +16 -16
  64. package/functions/bundleMinify.test.mjs +37 -37
  65. package/functions/compileReadme.mjs +9 -9
  66. package/functions/compileReadme.test.mjs +18 -18
  67. package/functions/copyFiles.mjs +32 -32
  68. package/functions/copyFiles.test.mjs +78 -78
  69. package/functions/copyFonts.mjs +9 -9
  70. package/functions/copyFonts.test.mjs +32 -32
  71. package/functions/default.mjs +12 -12
  72. package/functions/default.test.mjs +33 -33
  73. package/functions/dist.mjs +8 -8
  74. package/functions/dist.test.mjs +44 -44
  75. package/functions/distMinify.mjs +9 -9
  76. package/functions/distMinify.test.mjs +15 -15
  77. package/functions/docs.mjs +13 -13
  78. package/functions/docs.test.mjs +45 -45
  79. package/functions/gulpConfigEntries.test.mjs +23 -23
  80. package/functions/images.mjs +8 -8
  81. package/functions/images.test.mjs +140 -142
  82. package/functions/jsdocDocs.mjs +10 -10
  83. package/functions/jsdocEsmExports.test.mjs +24 -24
  84. package/functions/lint.mjs +9 -9
  85. package/functions/partials/addToReadme.mjs +25 -25
  86. package/functions/partials/addToReadme.test.mjs +34 -34
  87. package/functions/partials/beginWatcher.mjs +9 -9
  88. package/functions/partials/beginWatcher.test.mjs +19 -19
  89. package/functions/partials/cacheFiles.mjs +114 -0
  90. package/functions/partials/cacheFiles.test.mjs +151 -0
  91. package/functions/partials/clean.mjs +13 -13
  92. package/functions/partials/clean.test.mjs +22 -22
  93. package/functions/partials/copyFor.mjs +15 -15
  94. package/functions/partials/copyFor.test.mjs +53 -53
  95. package/functions/partials/distFor.mjs +22 -22
  96. package/functions/partials/distFor.test.mjs +195 -195
  97. package/functions/partials/distForSrc.mjs +11 -11
  98. package/functions/partials/distForSrc.test.mjs +18 -18
  99. package/functions/partials/distSeries.mjs +21 -21
  100. package/functions/partials/distSeries.test.mjs +34 -34
  101. package/functions/partials/imagesFor.mjs +147 -83
  102. package/functions/partials/imagesFor.test.mjs +311 -287
  103. package/functions/partials/jsdocDocsFor.mjs +163 -152
  104. package/functions/partials/jsdocDocsFor.test.mjs +182 -152
  105. package/functions/partials/lintSource.mjs +41 -41
  106. package/functions/partials/loadPeer.mjs +76 -76
  107. package/functions/partials/loadPeer.test.mjs +58 -58
  108. package/functions/partials/loadPlaywright.mjs +23 -23
  109. package/functions/partials/loadPlaywright.test.mjs +70 -70
  110. package/functions/partials/minifyFor.mjs +15 -15
  111. package/functions/partials/minifyFor.test.mjs +49 -49
  112. package/functions/partials/neostandardLint.mjs +142 -142
  113. package/functions/partials/neostandardLint.test.mjs +131 -131
  114. package/functions/partials/readmeTemplate.mjs +12 -12
  115. package/functions/partials/readmeTemplate.test.mjs +34 -34
  116. package/functions/partials/removeDirectory.mjs +34 -34
  117. package/functions/partials/removeDirectory.test.mjs +72 -72
  118. package/functions/partials/resolveDocsMethod.mjs +10 -10
  119. package/functions/partials/resolveDocsMethod.test.mjs +33 -33
  120. package/functions/partials/runOnChange.mjs +54 -54
  121. package/functions/partials/runOnChange.test.mjs +95 -95
  122. package/functions/partials/sassFor.mjs +25 -25
  123. package/functions/partials/sassFor.test.mjs +81 -81
  124. package/functions/partials/serveStatic.mjs +47 -47
  125. package/functions/partials/serveStatic.test.mjs +71 -71
  126. package/functions/partials/tsFor.mjs +92 -92
  127. package/functions/partials/tsFor.test.mjs +88 -88
  128. package/functions/partials/typeDocsFor.mjs +231 -231
  129. package/functions/partials/typeDocsFor.test.mjs +263 -263
  130. package/functions/partials.mjs +32 -31
  131. package/functions/partials.test.mjs +7 -7
  132. package/functions/sass.mjs +4 -4
  133. package/functions/sass.test.mjs +31 -31
  134. package/functions/sourceLint.mjs +13 -13
  135. package/functions/sourceLint.test.mjs +166 -166
  136. package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +40 -40
  137. package/functions/test-helpers/setUp.mjs +102 -100
  138. package/functions/test-helpers/setUp.test.mjs +19 -19
  139. package/functions/testFull.mjs +17 -17
  140. package/functions/testFull.test.mjs +17 -17
  141. package/functions/testHelpers.mjs +10 -10
  142. package/functions/testHelpers.test.mjs +7 -7
  143. package/functions/testQuick.mjs +17 -17
  144. package/functions/testQuick.test.mjs +17 -17
  145. package/functions/typeDocs.mjs +9 -9
  146. package/functions/typeDocs.test.mjs +11 -11
  147. package/functions/typeScript.mjs +8 -8
  148. package/functions/typeScript.test.mjs +11 -11
  149. package/functions/utilities/convertMjsFilesForDocs.mjs +34 -34
  150. package/functions/utilities/convertMjsFilesForDocs.test.mjs +58 -58
  151. package/functions/utilities/dotGet.mjs +49 -49
  152. package/functions/utilities/dotNotate.mjs +73 -73
  153. package/functions/utilities/dotNotate.test.mjs +41 -41
  154. package/functions/utilities/dotSet.mjs +40 -40
  155. package/functions/utilities/esmNamedExportsToCjs.mjs +30 -30
  156. package/functions/utilities/esmNamedExportsToCjs.test.mjs +47 -47
  157. package/functions/utilities/getBundleConfigs.mjs +30 -30
  158. package/functions/utilities/isObject.mjs +8 -8
  159. package/functions/utilities/strAfter.mjs +12 -12
  160. package/functions/utilities/strBefore.mjs +12 -12
  161. package/functions/watchFull.mjs +9 -9
  162. package/functions/watchFull.test.mjs +41 -41
  163. package/functions/watchTest.mjs +10 -10
  164. package/functions/watchTest.test.mjs +49 -49
  165. package/gulp.config.js +4 -4
  166. package/gulp.config.mjs +349 -340
  167. package/gulpfile.base.js +51 -51
  168. package/gulpfile.base.mjs +29 -29
  169. package/jsdoc.base.js +16 -16
  170. package/jsdoc.esmExports.js +17 -17
  171. package/package.json +146 -145
  172. package/dist/test-helpers/isolateGulpCache.js +0 -25
  173. package/functions/test-helpers/isolateGulpCache.mjs +0 -16
@@ -1,47 +1,47 @@
1
- import { esmNamedExportsToCjs } from './esmNamedExportsToCjs.mjs'
2
-
3
- describe('esmNamedExportsToCjs', () => {
4
- test('rewrites a single export const to a plain declaration plus a trailing module.exports', () => {
5
- const source = 'export const get = (path) => path\n'
6
- const result = esmNamedExportsToCjs(source)
7
- expect(result).toContain('const get = (path) => path')
8
- expect(result).toContain('module.exports = { get }')
9
- expect(result).not.toContain('export const')
10
- })
11
-
12
- test('rewrites multiple export const declarations into one module.exports with all the names', () => {
13
- const source = 'export const get = () => {}\nexport const set = () => {}\n'
14
- const result = esmNamedExportsToCjs(source)
15
- expect(result).toContain('const get = () => {}')
16
- expect(result).toContain('const set = () => {}')
17
- expect(result).toContain('module.exports = { get, set }')
18
- })
19
-
20
- test('rewrites export function and export class the same way', () => {
21
- const source = 'export function doThing() {}\nexport class Thing {}\n'
22
- const result = esmNamedExportsToCjs(source)
23
- expect(result).toContain('function doThing() {}')
24
- expect(result).toContain('class Thing {}')
25
- expect(result).toContain('module.exports = { doThing, Thing }')
26
- })
27
-
28
- test('leaves non-export lines and JSDoc comments untouched', () => {
29
- const source = '/**\n * A function.\n * @memberOf module:gulpConfig\n */\nexport const get = () => {}\n'
30
- const result = esmNamedExportsToCjs(source)
31
- expect(result).toContain('/**\n * A function.\n * @memberOf module:gulpConfig\n */\nconst get = () => {}')
32
- })
33
-
34
- test('does not add a module.exports block when there is nothing to export', () => {
35
- const source = 'import { thing } from \'./thing.mjs\'\nconst local = 1\n'
36
- const result = esmNamedExportsToCjs(source)
37
- expect(result).toBe(source)
38
- expect(result).not.toContain('module.exports')
39
- })
40
-
41
- test('leaves export default and other export forms untouched', () => {
42
- const source = 'const value = 1\nexport default value\n'
43
- const result = esmNamedExportsToCjs(source)
44
- expect(result).toContain('export default value')
45
- expect(result).not.toContain('module.exports')
46
- })
47
- })
1
+ import { esmNamedExportsToCjs } from './esmNamedExportsToCjs.mjs'
2
+
3
+ describe('esmNamedExportsToCjs', () => {
4
+ test('rewrites a single export const to a plain declaration plus a trailing module.exports', () => {
5
+ const source = 'export const get = (path) => path\n'
6
+ const result = esmNamedExportsToCjs(source)
7
+ expect(result).toContain('const get = (path) => path')
8
+ expect(result).toContain('module.exports = { get }')
9
+ expect(result).not.toContain('export const')
10
+ })
11
+
12
+ test('rewrites multiple export const declarations into one module.exports with all the names', () => {
13
+ const source = 'export const get = () => {}\nexport const set = () => {}\n'
14
+ const result = esmNamedExportsToCjs(source)
15
+ expect(result).toContain('const get = () => {}')
16
+ expect(result).toContain('const set = () => {}')
17
+ expect(result).toContain('module.exports = { get, set }')
18
+ })
19
+
20
+ test('rewrites export function and export class the same way', () => {
21
+ const source = 'export function doThing() {}\nexport class Thing {}\n'
22
+ const result = esmNamedExportsToCjs(source)
23
+ expect(result).toContain('function doThing() {}')
24
+ expect(result).toContain('class Thing {}')
25
+ expect(result).toContain('module.exports = { doThing, Thing }')
26
+ })
27
+
28
+ test('leaves non-export lines and JSDoc comments untouched', () => {
29
+ const source = '/**\n * A function.\n * @memberOf module:gulpConfig\n */\nexport const get = () => {}\n'
30
+ const result = esmNamedExportsToCjs(source)
31
+ expect(result).toContain('/**\n * A function.\n * @memberOf module:gulpConfig\n */\nconst get = () => {}')
32
+ })
33
+
34
+ test('does not add a module.exports block when there is nothing to export', () => {
35
+ const source = 'import { thing } from \'./thing.mjs\'\nconst local = 1\n'
36
+ const result = esmNamedExportsToCjs(source)
37
+ expect(result).toBe(source)
38
+ expect(result).not.toContain('module.exports')
39
+ })
40
+
41
+ test('leaves export default and other export forms untouched', () => {
42
+ const source = 'const value = 1\nexport default value\n'
43
+ const result = esmNamedExportsToCjs(source)
44
+ expect(result).toContain('export default value')
45
+ expect(result).not.toContain('module.exports')
46
+ })
47
+ })
@@ -1,30 +1,30 @@
1
- import * as gulpConfig from '../../gulp.config.mjs'
2
-
3
- /**
4
- * Build the full list of bundles to produce for this project: the primary bundle (browser.name /
5
- * dist.main / browser.ignore / browser.exclude, exactly as before browser.bundles existed) plus
6
- * any additional bundles from browser.bundles - each falling back to the primary's main / ignore /
7
- * exclude whenever its own isn't given, so a render-only (or any other variant) bundle only has to
8
- * specify what's actually different about it.
9
- * @memberOf module:utilities
10
- * @returns {Array<{name: string, main: string, ignore: Array, exclude: Array}>}
11
- * @private
12
- */
13
- export const getBundleConfigs = () => {
14
- const primary = {
15
- name: gulpConfig.get('browser.name'),
16
- main: gulpConfig.get('dist.main'),
17
- ignore: gulpConfig.get('browser.ignore'),
18
- exclude: gulpConfig.get('browser.exclude')
19
- }
20
- const additional = gulpConfig.get('browser.bundles')
21
- return [
22
- primary,
23
- ...additional.map((bundleConfig) => ({
24
- name: bundleConfig.name,
25
- main: bundleConfig.main || primary.main,
26
- ignore: bundleConfig.ignore || primary.ignore,
27
- exclude: bundleConfig.exclude || primary.exclude
28
- }))
29
- ]
30
- }
1
+ import * as gulpConfig from '../../gulp.config.mjs'
2
+
3
+ /**
4
+ * Build the full list of bundles to produce for this project: the primary bundle (browser.name /
5
+ * dist.main / browser.ignore / browser.exclude, exactly as before browser.bundles existed) plus
6
+ * any additional bundles from browser.bundles - each falling back to the primary's main / ignore /
7
+ * exclude whenever its own isn't given, so a render-only (or any other variant) bundle only has to
8
+ * specify what's actually different about it.
9
+ * @memberOf module:utilities
10
+ * @returns {Array<{name: string, main: string, ignore: Array, exclude: Array}>}
11
+ * @private
12
+ */
13
+ export const getBundleConfigs = () => {
14
+ const primary = {
15
+ name: gulpConfig.get('browser.name'),
16
+ main: gulpConfig.get('dist.main'),
17
+ ignore: gulpConfig.get('browser.ignore'),
18
+ exclude: gulpConfig.get('browser.exclude')
19
+ }
20
+ const additional = gulpConfig.get('browser.bundles')
21
+ return [
22
+ primary,
23
+ ...additional.map((bundleConfig) => ({
24
+ name: bundleConfig.name,
25
+ main: bundleConfig.main || primary.main,
26
+ ignore: bundleConfig.ignore || primary.ignore,
27
+ exclude: bundleConfig.exclude || primary.exclude
28
+ }))
29
+ ]
30
+ }
@@ -1,8 +1,8 @@
1
- /**
2
- * Check if the provided thing is an object / array.
3
- * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
4
- * @param {*} object
5
- * @returns {boolean}
6
- * @private
7
- */
8
- export const isObject = (object) => typeof object === 'object' && object !== null
1
+ /**
2
+ * Check if the provided thing is an object / array.
3
+ * Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
4
+ * @param {*} object
5
+ * @returns {boolean}
6
+ * @private
7
+ */
8
+ export const isObject = (object) => typeof object === 'object' && object !== null
@@ -1,12 +1,12 @@
1
- /**
2
- * Retrieve the string part after the search match.
3
- * Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strAfter.ts Sí, funciona}
4
- * @param {string} str
5
- * @param {string} search
6
- * @returns {string}
7
- * @private
8
- */
9
- export const strAfter = (str, search) => {
10
- const index = str.indexOf(search)
11
- return index === -1 ? '' : str.substring(index + search.length)
12
- }
1
+ /**
2
+ * Retrieve the string part after the search match.
3
+ * Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strAfter.ts Sí, funciona}
4
+ * @param {string} str
5
+ * @param {string} search
6
+ * @returns {string}
7
+ * @private
8
+ */
9
+ export const strAfter = (str, search) => {
10
+ const index = str.indexOf(search)
11
+ return index === -1 ? '' : str.substring(index + search.length)
12
+ }
@@ -1,12 +1,12 @@
1
- /**
2
- * Retrieve the string part before the search match.
3
- * Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strBefore.ts Sí, funciona}
4
- * @param {string} str
5
- * @param {string} search
6
- * @returns {string}
7
- * @private
8
- */
9
- export const strBefore = (str, search) => {
10
- const index = str.indexOf(search)
11
- return index === -1 ? '' : str.slice(0, index)
12
- }
1
+ /**
2
+ * Retrieve the string part before the search match.
3
+ * Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strBefore.ts Sí, funciona}
4
+ * @param {string} str
5
+ * @param {string} search
6
+ * @returns {string}
7
+ * @private
8
+ */
9
+ export const strBefore = (str, search) => {
10
+ const index = str.indexOf(search)
11
+ return index === -1 ? '' : str.slice(0, index)
12
+ }
@@ -1,9 +1,9 @@
1
- import { beginWatcher, runOnChange } from './partials.mjs'
2
-
3
- /**
4
- * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
5
- * @memberOf module:js-build-tools
6
- * @returns {FSWatcher}
7
- */
8
- export const watchFull = () => beginWatcher()
9
- .on('change', runOnChange)
1
+ import { beginWatcher, runOnChange } from './partials.mjs'
2
+
3
+ /**
4
+ * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
5
+ * @memberOf module:js-build-tools
6
+ * @returns {FSWatcher}
7
+ */
8
+ export const watchFull = () => beginWatcher()
9
+ .on('change', runOnChange)
@@ -1,41 +1,41 @@
1
- import fs from 'fs'
2
- import * as setUp from './test-helpers/setUp.mjs'
3
- import { watchFull } from './watchFull.mjs'
4
- import { beginWatcher } from './partials/beginWatcher.mjs'
5
- import { runOnChange } from './partials/runOnChange.mjs'
6
-
7
- setUp.setDefaults('test-watch-full')
8
- const gulpConfig = setUp.gulpConfig
9
-
10
- jest.mock('./partials/beginWatcher.mjs', () => ({ beginWatcher: jest.fn(() => ({ on: (event, fn) => fn() })) }))
11
- jest.mock('./partials/runOnChange.mjs', () => ({ runOnChange: jest.fn() }))
12
-
13
- const rawContents = 'const { beginWatcher, runOnChange } = require(\'./partials\')\n' +
14
- '\n' +
15
- '/**\n' +
16
- ' * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.\n' +
17
- ' * @function\n' +
18
- ' * @memberOf module:js-build-tools\n' +
19
- ' * @returns {FSWatcher}\n' +
20
- ' */\n' +
21
- 'const watchFull = () => beginWatcher()\n' +
22
- ' .on(\'change\', runOnChange)\n' +
23
- '\n' +
24
- 'module.exports = watchFull\n'
25
-
26
- beforeEach(setUp.beforeEach)
27
-
28
- afterEach(setUp.afterEach)
29
-
30
- describe('watchFull', () => {
31
- test('should call beginWatcher and runOnChange for change event', () => {
32
- const srcPath = gulpConfig.get('srcPath')
33
- gulpConfig.set('test.watch', `${srcPath}/*.js`)
34
- const srcFile = `${srcPath}/watchFull.js`
35
- fs.writeFileSync(srcFile, rawContents)
36
- expect.assertions(2)
37
- watchFull()
38
- expect(beginWatcher).toHaveBeenCalled()
39
- expect(runOnChange).toHaveBeenCalled()
40
- })
41
- })
1
+ import fs from 'fs'
2
+ import * as setUp from './test-helpers/setUp.mjs'
3
+ import { watchFull } from './watchFull.mjs'
4
+ import { beginWatcher } from './partials/beginWatcher.mjs'
5
+ import { runOnChange } from './partials/runOnChange.mjs'
6
+
7
+ setUp.setDefaults('test-watch-full')
8
+ const gulpConfig = setUp.gulpConfig
9
+
10
+ jest.mock('./partials/beginWatcher.mjs', () => ({ beginWatcher: jest.fn(() => ({ on: (event, fn) => fn() })) }))
11
+ jest.mock('./partials/runOnChange.mjs', () => ({ runOnChange: jest.fn() }))
12
+
13
+ const rawContents = 'const { beginWatcher, runOnChange } = require(\'./partials\')\n' +
14
+ '\n' +
15
+ '/**\n' +
16
+ ' * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.\n' +
17
+ ' * @function\n' +
18
+ ' * @memberOf module:js-build-tools\n' +
19
+ ' * @returns {FSWatcher}\n' +
20
+ ' */\n' +
21
+ 'const watchFull = () => beginWatcher()\n' +
22
+ ' .on(\'change\', runOnChange)\n' +
23
+ '\n' +
24
+ 'module.exports = watchFull\n'
25
+
26
+ beforeEach(setUp.beforeEach)
27
+
28
+ afterEach(setUp.afterEach)
29
+
30
+ describe('watchFull', () => {
31
+ test('should call beginWatcher and runOnChange for change event', () => {
32
+ const srcPath = gulpConfig.get('srcPath')
33
+ gulpConfig.set('test.watch', `${srcPath}/*.js`)
34
+ const srcFile = `${srcPath}/watchFull.js`
35
+ fs.writeFileSync(srcFile, rawContents)
36
+ expect.assertions(2)
37
+ watchFull()
38
+ expect(beginWatcher).toHaveBeenCalled()
39
+ expect(runOnChange).toHaveBeenCalled()
40
+ })
41
+ })
@@ -1,10 +1,10 @@
1
- import * as gulpConfig from '../gulp.config.mjs'
2
- import { watch } from 'gulp'
3
- import { testQuick } from './testQuick.mjs'
4
-
5
- /**
6
- * Watch for changes and run the tests.
7
- * @memberOf module:js-build-tools
8
- * @returns {*}
9
- */
10
- export const watchTest = () => watch(gulpConfig.get('test.watch'), { ignoreInitial: false }, testQuick)
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { watch } from 'gulp'
3
+ import { testQuick } from './testQuick.mjs'
4
+
5
+ /**
6
+ * Watch for changes and run the tests.
7
+ * @memberOf module:js-build-tools
8
+ * @returns {*}
9
+ */
10
+ export const watchTest = () => watch(gulpConfig.get('test.watch'), { ignoreInitial: false }, testQuick)
@@ -1,49 +1,49 @@
1
- import * as setUp from './test-helpers/setUp.mjs'
2
- import { watchTest } from './watchTest.mjs'
3
- import { EventEmitter } from 'node:events'
4
- import fs from 'fs'
5
- import { testQuick } from './testQuick.mjs'
6
-
7
- setUp.setDefaults('test-watch-test')
8
- const gulpConfig = setUp.gulpConfig
9
- gulpConfig.set('test.watch', 'test-begin-watcher/*.js')
10
-
11
- jest.mock('./testQuick.mjs', () => ({ testQuick: jest.fn(() => Promise.resolve(true)) }))
12
-
13
- const rawContents = 'const gulpConfig = require(\'../gulp.config.js\')\n' +
14
- 'const { watch } = require(\'gulp\')\n' +
15
- 'const testQuick = require(\'./testQuick\')\n' +
16
- '\n' +
17
- '/**\n' +
18
- ' * Watch for changes and run the tests.\n' +
19
- ' * @function\n' +
20
- ' * @memberOf module:js-build-tools\n' +
21
- ' * @returns {*}\n' +
22
- ' */\n' +
23
- 'const watchTest = () => watch(gulpConfig.get(\'watchSearch\'), { ignoreInitial: false }, testQuick)\n' +
24
- '\n' +
25
- 'module.exports = watchTest\n'
26
-
27
- const filePath = gulpConfig.get('srcPath') + '/watchTest.js'
28
-
29
- beforeEach(() => setUp.beforeEach()
30
- .then(
31
- () => fs.writeFileSync(filePath, rawContents)
32
- )
33
- )
34
-
35
- afterEach(setUp.afterEach)
36
-
37
- describe('watchTest', () => {
38
- test('returns instance of EventEmitter / FSWatcher and calls testQuick on change', done => {
39
- expect.assertions(2)
40
- const fsWatcher = watchTest()
41
- expect(fsWatcher).toBeInstanceOf(EventEmitter)
42
- fsWatcher.emit('change')
43
- setTimeout(() => {
44
- expect(testQuick).toHaveBeenCalled()
45
- done()
46
- }, 500)
47
- fsWatcher.close()
48
- })
49
- })
1
+ import * as setUp from './test-helpers/setUp.mjs'
2
+ import { watchTest } from './watchTest.mjs'
3
+ import { EventEmitter } from 'node:events'
4
+ import fs from 'fs'
5
+ import { testQuick } from './testQuick.mjs'
6
+
7
+ setUp.setDefaults('test-watch-test')
8
+ const gulpConfig = setUp.gulpConfig
9
+ gulpConfig.set('test.watch', 'test-begin-watcher/*.js')
10
+
11
+ jest.mock('./testQuick.mjs', () => ({ testQuick: jest.fn(() => Promise.resolve(true)) }))
12
+
13
+ const rawContents = 'const gulpConfig = require(\'../gulp.config.js\')\n' +
14
+ 'const { watch } = require(\'gulp\')\n' +
15
+ 'const testQuick = require(\'./testQuick\')\n' +
16
+ '\n' +
17
+ '/**\n' +
18
+ ' * Watch for changes and run the tests.\n' +
19
+ ' * @function\n' +
20
+ ' * @memberOf module:js-build-tools\n' +
21
+ ' * @returns {*}\n' +
22
+ ' */\n' +
23
+ 'const watchTest = () => watch(gulpConfig.get(\'watchSearch\'), { ignoreInitial: false }, testQuick)\n' +
24
+ '\n' +
25
+ 'module.exports = watchTest\n'
26
+
27
+ const filePath = gulpConfig.get('srcPath') + '/watchTest.js'
28
+
29
+ beforeEach(() => setUp.beforeEach()
30
+ .then(
31
+ () => fs.writeFileSync(filePath, rawContents)
32
+ )
33
+ )
34
+
35
+ afterEach(setUp.afterEach)
36
+
37
+ describe('watchTest', () => {
38
+ test('returns instance of EventEmitter / FSWatcher and calls testQuick on change', done => {
39
+ expect.assertions(2)
40
+ const fsWatcher = watchTest()
41
+ expect(fsWatcher).toBeInstanceOf(EventEmitter)
42
+ fsWatcher.emit('change')
43
+ setTimeout(() => {
44
+ expect(testQuick).toHaveBeenCalled()
45
+ done()
46
+ }, 500)
47
+ fsWatcher.close()
48
+ })
49
+ })
package/gulp.config.js CHANGED
@@ -1,4 +1,4 @@
1
- // gulp.config.mjs is the single source of truth. This CommonJS entry re-exports it, so CommonJS consumers
2
- // (dist/*.js, jsdoc.base.js, require('js-build-tools/gulp.config')) read exactly the same configuration.
3
- // Relies on require(esm), which Node 22.12+ supports natively.
4
- module.exports = require('./gulp.config.mjs')
1
+ // gulp.config.mjs is the single source of truth. This CommonJS entry re-exports it, so CommonJS consumers
2
+ // (dist/*.js, jsdoc.base.js, require('js-build-tools/gulp.config')) read exactly the same configuration.
3
+ // Relies on require(esm), which Node 22.12+ supports natively.
4
+ module.exports = require('./gulp.config.mjs')