js-build-tools 6.5.0 → 6.7.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 (169) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +762 -692
  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/clean.js +5 -5
  20. package/dist/partials/copyFor.js +9 -9
  21. package/dist/partials/distFor.js +6 -6
  22. package/dist/partials/distForSrc.js +5 -5
  23. package/dist/partials/distSeries.js +7 -7
  24. package/dist/partials/imagesFor.js +93 -56
  25. package/dist/partials/jsdocDocsFor.js +46 -46
  26. package/dist/partials/lintSource.js +51 -51
  27. package/dist/partials/loadPeer.js +99 -99
  28. package/dist/partials/loadPlaywright.js +14 -14
  29. package/dist/partials/minifyFor.js +20 -20
  30. package/dist/partials/neostandardLint.js +175 -175
  31. package/dist/partials/readmeTemplate.js +4 -4
  32. package/dist/partials/removeDirectory.js +11 -11
  33. package/dist/partials/resolveDocsMethod.js +6 -6
  34. package/dist/partials/runOnChange.js +31 -31
  35. package/dist/partials/sassFor.js +6 -6
  36. package/dist/partials/serveStatic.js +9 -9
  37. package/dist/partials/tsFor.js +32 -32
  38. package/dist/partials/typeDocsFor.js +57 -51
  39. package/dist/partials.js +176 -176
  40. package/dist/sourceLint.js +18 -18
  41. package/dist/test-helpers/isolateGulpCache.js +24 -24
  42. package/dist/test-helpers/setUp.js +4 -4
  43. package/dist/testFull.js +5 -5
  44. package/dist/testQuick.js +5 -5
  45. package/dist/typeDocs.js +5 -5
  46. package/dist/typeScript.js +4 -4
  47. package/dist/utilities/convertMjsFilesForDocs.js +12 -12
  48. package/dist/utilities/dotGet.js +54 -54
  49. package/dist/utilities/dotNotate.js +79 -79
  50. package/dist/utilities/dotSet.js +45 -45
  51. package/dist/utilities/esmNamedExportsToCjs.js +15 -15
  52. package/dist/utilities/getBundleConfigs.js +9 -9
  53. package/dist/utilities/isObject.js +6 -6
  54. package/dist/utilities/strAfter.js +7 -7
  55. package/dist/utilities/strBefore.js +7 -7
  56. package/dist/watchFull.js +4 -4
  57. package/dist/watchTest.js +4 -4
  58. package/functions/build.mjs +72 -72
  59. package/functions/build.test.mjs +763 -759
  60. package/functions/bundle.mjs +44 -44
  61. package/functions/bundle.test.mjs +219 -219
  62. package/functions/bundleMinify.mjs +16 -16
  63. package/functions/bundleMinify.test.mjs +37 -37
  64. package/functions/compileReadme.mjs +9 -9
  65. package/functions/compileReadme.test.mjs +18 -18
  66. package/functions/copyFiles.mjs +32 -32
  67. package/functions/copyFiles.test.mjs +78 -78
  68. package/functions/copyFonts.mjs +9 -9
  69. package/functions/copyFonts.test.mjs +32 -32
  70. package/functions/default.mjs +12 -12
  71. package/functions/default.test.mjs +33 -33
  72. package/functions/dist.mjs +8 -8
  73. package/functions/dist.test.mjs +44 -44
  74. package/functions/distMinify.mjs +9 -9
  75. package/functions/distMinify.test.mjs +15 -15
  76. package/functions/docs.mjs +13 -13
  77. package/functions/docs.test.mjs +45 -45
  78. package/functions/gulpConfigEntries.test.mjs +23 -23
  79. package/functions/images.mjs +8 -8
  80. package/functions/images.test.mjs +142 -142
  81. package/functions/jsdocDocs.mjs +10 -10
  82. package/functions/jsdocEsmExports.test.mjs +24 -24
  83. package/functions/lint.mjs +9 -9
  84. package/functions/partials/addToReadme.mjs +25 -25
  85. package/functions/partials/addToReadme.test.mjs +34 -34
  86. package/functions/partials/beginWatcher.mjs +9 -9
  87. package/functions/partials/beginWatcher.test.mjs +19 -19
  88. package/functions/partials/clean.mjs +13 -13
  89. package/functions/partials/clean.test.mjs +22 -22
  90. package/functions/partials/copyFor.mjs +15 -15
  91. package/functions/partials/copyFor.test.mjs +53 -53
  92. package/functions/partials/distFor.mjs +22 -22
  93. package/functions/partials/distFor.test.mjs +195 -195
  94. package/functions/partials/distForSrc.mjs +11 -11
  95. package/functions/partials/distForSrc.test.mjs +18 -18
  96. package/functions/partials/distSeries.mjs +21 -21
  97. package/functions/partials/distSeries.test.mjs +34 -34
  98. package/functions/partials/imagesFor.mjs +83 -50
  99. package/functions/partials/imagesFor.test.mjs +287 -229
  100. package/functions/partials/jsdocDocsFor.mjs +163 -152
  101. package/functions/partials/jsdocDocsFor.test.mjs +182 -152
  102. package/functions/partials/lintSource.mjs +41 -41
  103. package/functions/partials/loadPeer.mjs +76 -76
  104. package/functions/partials/loadPeer.test.mjs +58 -58
  105. package/functions/partials/loadPlaywright.mjs +23 -23
  106. package/functions/partials/loadPlaywright.test.mjs +70 -70
  107. package/functions/partials/minifyFor.mjs +15 -15
  108. package/functions/partials/minifyFor.test.mjs +49 -49
  109. package/functions/partials/neostandardLint.mjs +142 -142
  110. package/functions/partials/neostandardLint.test.mjs +131 -131
  111. package/functions/partials/readmeTemplate.mjs +12 -12
  112. package/functions/partials/readmeTemplate.test.mjs +34 -34
  113. package/functions/partials/removeDirectory.mjs +34 -34
  114. package/functions/partials/removeDirectory.test.mjs +72 -72
  115. package/functions/partials/resolveDocsMethod.mjs +10 -10
  116. package/functions/partials/resolveDocsMethod.test.mjs +33 -33
  117. package/functions/partials/runOnChange.mjs +54 -54
  118. package/functions/partials/runOnChange.test.mjs +95 -95
  119. package/functions/partials/sassFor.mjs +25 -25
  120. package/functions/partials/sassFor.test.mjs +81 -81
  121. package/functions/partials/serveStatic.mjs +47 -47
  122. package/functions/partials/serveStatic.test.mjs +71 -71
  123. package/functions/partials/tsFor.mjs +92 -92
  124. package/functions/partials/tsFor.test.mjs +88 -88
  125. package/functions/partials/typeDocsFor.mjs +231 -227
  126. package/functions/partials/typeDocsFor.test.mjs +263 -252
  127. package/functions/partials.mjs +31 -31
  128. package/functions/partials.test.mjs +7 -7
  129. package/functions/sass.mjs +4 -4
  130. package/functions/sass.test.mjs +31 -31
  131. package/functions/sourceLint.mjs +13 -13
  132. package/functions/sourceLint.test.mjs +166 -166
  133. package/functions/test-helpers/isolateGulpCache.mjs +16 -16
  134. package/functions/test-helpers/neostandardLintWithRealNeostandard.mjs +40 -40
  135. package/functions/test-helpers/setUp.mjs +100 -100
  136. package/functions/test-helpers/setUp.test.mjs +19 -19
  137. package/functions/testFull.mjs +17 -17
  138. package/functions/testFull.test.mjs +17 -17
  139. package/functions/testHelpers.mjs +10 -10
  140. package/functions/testHelpers.test.mjs +7 -7
  141. package/functions/testQuick.mjs +17 -17
  142. package/functions/testQuick.test.mjs +17 -17
  143. package/functions/typeDocs.mjs +9 -9
  144. package/functions/typeDocs.test.mjs +11 -11
  145. package/functions/typeScript.mjs +8 -8
  146. package/functions/typeScript.test.mjs +11 -11
  147. package/functions/utilities/convertMjsFilesForDocs.mjs +34 -34
  148. package/functions/utilities/convertMjsFilesForDocs.test.mjs +58 -58
  149. package/functions/utilities/dotGet.mjs +49 -49
  150. package/functions/utilities/dotNotate.mjs +73 -73
  151. package/functions/utilities/dotNotate.test.mjs +41 -41
  152. package/functions/utilities/dotSet.mjs +40 -40
  153. package/functions/utilities/esmNamedExportsToCjs.mjs +30 -30
  154. package/functions/utilities/esmNamedExportsToCjs.test.mjs +47 -47
  155. package/functions/utilities/getBundleConfigs.mjs +30 -30
  156. package/functions/utilities/isObject.mjs +8 -8
  157. package/functions/utilities/strAfter.mjs +12 -12
  158. package/functions/utilities/strBefore.mjs +12 -12
  159. package/functions/watchFull.mjs +9 -9
  160. package/functions/watchFull.test.mjs +41 -41
  161. package/functions/watchTest.mjs +10 -10
  162. package/functions/watchTest.test.mjs +49 -49
  163. package/gulp.config.js +4 -4
  164. package/gulp.config.mjs +344 -327
  165. package/gulpfile.base.js +51 -51
  166. package/gulpfile.base.mjs +29 -29
  167. package/jsdoc.base.js +16 -16
  168. package/jsdoc.esmExports.js +17 -17
  169. package/package.json +146 -145
@@ -1,100 +1,100 @@
1
- // Import the configurations and override some of them to direct to the temp directory.
2
- import * as gulpConfig from '../../gulp.config.mjs'
3
- import { setUp } from 'test-filesystem'
4
-
5
- let tempDir = 'test-temp/'
6
- let srcPath = `${tempDir}src`
7
-
8
- /**
9
- * Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
10
- * @memberOf module:testHelpers
11
- * @param {string} testDir
12
- */
13
- export const setDefaults = (testDir = 'test-temp') => {
14
- tempDir = `${testDir}/`
15
- srcPath = `${tempDir}src`
16
- setUp.setDefaults(tempDir)
17
- const distPath = `${tempDir}dist`
18
- const browserPath = `${tempDir}browser`
19
- const sassPath = `${tempDir}sass`
20
- gulpConfig.set('browser.from', `${distPath}/**/*.js`)
21
- gulpConfig.set('browser.to', browserPath)
22
- gulpConfig.set('cleanPaths', [distPath, browserPath])
23
- gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`)
24
- gulpConfig.set('dist.main', `${distPath}/main`)
25
- gulpConfig.set('dist.to', distPath)
26
- // Reset explicitly, for the same reason as readme.fromEsm below: this project's own build-tools.config.json turns
27
- // docs on and points them at the website checkout, which would leak into every test that never sets these itself.
28
- gulpConfig.set('docs.enabled', false)
29
- gulpConfig.set('docs.from', srcPath)
30
- gulpConfig.set('docs.to', `${tempDir}docs`)
31
- gulpConfig.set('docs.title', '')
32
- gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`)
33
- gulpConfig.set('fonts.to', `${browserPath}/fonts`)
34
- gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`)
35
- gulpConfig.set('images.to', `${browserPath}/img`)
36
- gulpConfig.set('readme.template', `${tempDir}MAIN.md`)
37
- gulpConfig.set('readme.to', tempDir)
38
- gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`)
39
- // Reset explicitly: gulpConfig is a process-wide singleton seeded once from this real project's own
40
- // build-tools.config.json, so without this, this project's own real readme.fromEsm value (gulp.config.mjs)
41
- // would leak into every test that exercises addToReadme/compileReadme but never sets this path itself -
42
- // doing real file I/O and a real jsdoc-to-markdown parse of this project's own, much larger, config file.
43
- gulpConfig.set('readme.fromEsm', [])
44
- gulpConfig.set('rootPath', tempDir)
45
- gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`)
46
- gulpConfig.set('sass.path', sassPath)
47
- gulpConfig.set('sass.to', `${browserPath}/css`)
48
- gulpConfig.set('srcPath', srcPath)
49
- gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`)
50
- gulpConfig.set('typescript.to', distPath)
51
- gulpConfig.set('test.watch', `${srcPath}/**/*.js`)
52
- }
53
-
54
- export { gulpConfig }
55
-
56
- export {
57
- /**
58
- * Ensure that the del has completed, recursively attempt to delete and recreate
59
- * @memberOf module:testHelpers
60
- * @param {boolean} [exists=true]
61
- * @returns {Promise<*|void>}
62
- */
63
- createTempDir,
64
- /**
65
- * In the Jest.beforeEach function call this one to set up the temp directory.
66
- * @memberOf module:testHelpers
67
- * @returns {Promise<*|void>}
68
- */
69
- beforeEach,
70
- /**
71
- * In the Jest.afterEach function call this one to clean up and remove the temp directory.
72
- * @memberOf module:testHelpers
73
- * @returns {Promise<*>}
74
- */
75
- afterEach,
76
- /**
77
- * Return number of occurrences of substring in another string.
78
- * @memberOf module:testHelpers
79
- * @returns {int}
80
- */
81
- countMatches,
82
- /**
83
- * Returns true if the given file or directory exists, otherwise false.
84
- * @memberOf module:testHelpers
85
- * @returns {boolean}
86
- */
87
- fileExists,
88
- /**
89
- * Console log objects in a readable format, returns the given object.
90
- * @memberOf module:testHelpers
91
- * @returns {*}
92
- */
93
- logObject,
94
- /**
95
- * Delete a directory and subcontents.
96
- * @memberOf module:testHelpers
97
- * @returns {Promise<*>}
98
- */
99
- removeDirectory,
100
- } from 'test-filesystem'
1
+ // Import the configurations and override some of them to direct to the temp directory.
2
+ import * as gulpConfig from '../../gulp.config.mjs'
3
+ import { setUp } from 'test-filesystem'
4
+
5
+ let tempDir = 'test-temp/'
6
+ let srcPath = `${tempDir}src`
7
+
8
+ /**
9
+ * Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
10
+ * @memberOf module:testHelpers
11
+ * @param {string} testDir
12
+ */
13
+ export const setDefaults = (testDir = 'test-temp') => {
14
+ tempDir = `${testDir}/`
15
+ srcPath = `${tempDir}src`
16
+ setUp.setDefaults(tempDir)
17
+ const distPath = `${tempDir}dist`
18
+ const browserPath = `${tempDir}browser`
19
+ const sassPath = `${tempDir}sass`
20
+ gulpConfig.set('browser.from', `${distPath}/**/*.js`)
21
+ gulpConfig.set('browser.to', browserPath)
22
+ gulpConfig.set('cleanPaths', [distPath, browserPath])
23
+ gulpConfig.set('dist.from', `${srcPath}/**/!(*.test).js`)
24
+ gulpConfig.set('dist.main', `${distPath}/main`)
25
+ gulpConfig.set('dist.to', distPath)
26
+ // Reset explicitly, for the same reason as readme.fromEsm below: this project's own build-tools.config.json turns
27
+ // docs on and points them at the website checkout, which would leak into every test that never sets these itself.
28
+ gulpConfig.set('docs.enabled', false)
29
+ gulpConfig.set('docs.from', srcPath)
30
+ gulpConfig.set('docs.to', `${tempDir}docs`)
31
+ gulpConfig.set('docs.title', '')
32
+ gulpConfig.set('fonts.from', `${srcPath}/fonts/**/*`)
33
+ gulpConfig.set('fonts.to', `${browserPath}/fonts`)
34
+ gulpConfig.set('images.from', `${srcPath}/img/**/*.+(png|jpg|jpeg|gif|svg)`)
35
+ gulpConfig.set('images.to', `${browserPath}/img`)
36
+ gulpConfig.set('readme.template', `${tempDir}MAIN.md`)
37
+ gulpConfig.set('readme.to', tempDir)
38
+ gulpConfig.set('readme.from', `${srcPath}/**/!(*.test).js`)
39
+ // Reset explicitly: gulpConfig is a process-wide singleton seeded once from this real project's own
40
+ // build-tools.config.json, so without this, this project's own real readme.fromEsm value (gulp.config.mjs)
41
+ // would leak into every test that exercises addToReadme/compileReadme but never sets this path itself -
42
+ // doing real file I/O and a real jsdoc-to-markdown parse of this project's own, much larger, config file.
43
+ gulpConfig.set('readme.fromEsm', [])
44
+ gulpConfig.set('rootPath', tempDir)
45
+ gulpConfig.set('sass.from', `${sassPath}/**/*.+(scss|sass)`)
46
+ gulpConfig.set('sass.path', sassPath)
47
+ gulpConfig.set('sass.to', `${browserPath}/css`)
48
+ gulpConfig.set('srcPath', srcPath)
49
+ gulpConfig.set('typescript.from', `${srcPath}/**/*.ts`)
50
+ gulpConfig.set('typescript.to', distPath)
51
+ gulpConfig.set('test.watch', `${srcPath}/**/*.js`)
52
+ }
53
+
54
+ export { gulpConfig }
55
+
56
+ export {
57
+ /**
58
+ * Ensure that the del has completed, recursively attempt to delete and recreate
59
+ * @memberOf module:testHelpers
60
+ * @param {boolean} [exists=true]
61
+ * @returns {Promise<*|void>}
62
+ */
63
+ createTempDir,
64
+ /**
65
+ * In the Jest.beforeEach function call this one to set up the temp directory.
66
+ * @memberOf module:testHelpers
67
+ * @returns {Promise<*|void>}
68
+ */
69
+ beforeEach,
70
+ /**
71
+ * In the Jest.afterEach function call this one to clean up and remove the temp directory.
72
+ * @memberOf module:testHelpers
73
+ * @returns {Promise<*>}
74
+ */
75
+ afterEach,
76
+ /**
77
+ * Return number of occurrences of substring in another string.
78
+ * @memberOf module:testHelpers
79
+ * @returns {int}
80
+ */
81
+ countMatches,
82
+ /**
83
+ * Returns true if the given file or directory exists, otherwise false.
84
+ * @memberOf module:testHelpers
85
+ * @returns {boolean}
86
+ */
87
+ fileExists,
88
+ /**
89
+ * Console log objects in a readable format, returns the given object.
90
+ * @memberOf module:testHelpers
91
+ * @returns {*}
92
+ */
93
+ logObject,
94
+ /**
95
+ * Delete a directory and subcontents.
96
+ * @memberOf module:testHelpers
97
+ * @returns {Promise<*>}
98
+ */
99
+ removeDirectory,
100
+ } from 'test-filesystem'
@@ -1,19 +1,19 @@
1
- import { afterEach, createTempDir, gulpConfig, setDefaults } from './setUp.mjs'
2
- import fs from 'fs'
3
-
4
- setDefaults()
5
-
6
- describe('setUp', () => {
7
- test('able to create the test-temp/src directory', async () => {
8
- const srcPath = gulpConfig.get('srcPath')
9
- expect(fs.existsSync(srcPath)).toBeFalsy()
10
- await createTempDir()
11
- expect(fs.existsSync(srcPath)).toBeTruthy()
12
- })
13
-
14
- test('able to delete the test-temp/src directory', async () => {
15
- expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeTruthy()
16
- await afterEach()
17
- expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeFalsy()
18
- })
19
- })
1
+ import { afterEach, createTempDir, gulpConfig, setDefaults } from './setUp.mjs'
2
+ import fs from 'fs'
3
+
4
+ setDefaults()
5
+
6
+ describe('setUp', () => {
7
+ test('able to create the test-temp/src directory', async () => {
8
+ const srcPath = gulpConfig.get('srcPath')
9
+ expect(fs.existsSync(srcPath)).toBeFalsy()
10
+ await createTempDir()
11
+ expect(fs.existsSync(srcPath)).toBeTruthy()
12
+ })
13
+
14
+ test('able to delete the test-temp/src directory', async () => {
15
+ expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeTruthy()
16
+ await afterEach()
17
+ expect(fs.existsSync(gulpConfig.get('srcPath'))).toBeFalsy()
18
+ })
19
+ })
@@ -1,17 +1,17 @@
1
- import * as gulpConfig from '../gulp.config.mjs'
2
- import { runCLI } from 'jest'
3
-
4
- /**
5
- * Run all tests with jest.
6
- * Configure where tests are located by using 'testPath'.
7
- * @memberOf module:js-build-tools
8
- * @returns {Promise<*>}
9
- */
10
- export const testFull = () => {
11
- let testPath = gulpConfig.get('test.path')
12
- if (!Array.isArray(testPath)) {
13
- // The testPath must be an array of strings
14
- testPath = [testPath]
15
- }
16
- return runCLI(gulpConfig.get('test.options'), testPath)
17
- }
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { runCLI } from 'jest'
3
+
4
+ /**
5
+ * Run all tests with jest.
6
+ * Configure where tests are located by using 'testPath'.
7
+ * @memberOf module:js-build-tools
8
+ * @returns {Promise<*>}
9
+ */
10
+ export const testFull = () => {
11
+ let testPath = gulpConfig.get('test.path')
12
+ if (!Array.isArray(testPath)) {
13
+ // The testPath must be an array of strings
14
+ testPath = [testPath]
15
+ }
16
+ return runCLI(gulpConfig.get('test.options'), testPath)
17
+ }
@@ -1,17 +1,17 @@
1
- import { testHelpers } from './testHelpers.mjs'
2
- import { runCLI } from 'jest'
3
- import { testFull } from './testFull.mjs'
4
-
5
- const gulpConfig = testHelpers.gulpConfig
6
-
7
- jest.mock('jest', () => ({
8
- runCLI: jest.fn(() => Promise.resolve(true))
9
- }))
10
-
11
- describe('testFull', () => {
12
- test('runs the Jest CLI with the configured options', () => {
13
- expect.assertions(1)
14
- testFull()
15
- expect(runCLI).toHaveBeenCalledWith(gulpConfig.get('test.options'), [gulpConfig.get('test.path')])
16
- })
17
- })
1
+ import { testHelpers } from './testHelpers.mjs'
2
+ import { runCLI } from 'jest'
3
+ import { testFull } from './testFull.mjs'
4
+
5
+ const gulpConfig = testHelpers.gulpConfig
6
+
7
+ jest.mock('jest', () => ({
8
+ runCLI: jest.fn(() => Promise.resolve(true))
9
+ }))
10
+
11
+ describe('testFull', () => {
12
+ test('runs the Jest CLI with the configured options', () => {
13
+ expect.assertions(1)
14
+ testFull()
15
+ expect(runCLI).toHaveBeenCalledWith(gulpConfig.get('test.options'), [gulpConfig.get('test.path')])
16
+ })
17
+ })
@@ -1,10 +1,10 @@
1
- /**
2
- * Export the setUp helper.
3
- * @file
4
- * @author Joshua Heagle <joshuaheagle@gmail.com>
5
- * @version 3.0.0
6
- * @module testHelpers
7
- * @memberOf module:js-build-tools
8
- */
9
-
10
- export * as testHelpers from './test-helpers/setUp.mjs'
1
+ /**
2
+ * Export the setUp helper.
3
+ * @file
4
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
5
+ * @version 3.0.0
6
+ * @module testHelpers
7
+ * @memberOf module:js-build-tools
8
+ */
9
+
10
+ export * as testHelpers from './test-helpers/setUp.mjs'
@@ -1,7 +1,7 @@
1
- import { testHelpers } from './testHelpers.mjs'
2
-
3
- describe('testHelpers', () => {
4
- test('is object with all helper exports', () => {
5
- expect(Object.keys(testHelpers).length).toBe(9)
6
- })
7
- })
1
+ import { testHelpers } from './testHelpers.mjs'
2
+
3
+ describe('testHelpers', () => {
4
+ test('is object with all helper exports', () => {
5
+ expect(Object.keys(testHelpers).length).toBe(9)
6
+ })
7
+ })
@@ -1,17 +1,17 @@
1
- import * as gulpConfig from '../gulp.config.mjs'
2
- import { runCLI } from 'jest'
3
-
4
- /**
5
- * Run the Jest tests for files which have been modified (based on git status).
6
- * Configure where tests are located by using 'testPath'.
7
- * @memberOf module:js-build-tools
8
- * @returns {Promise<*>}
9
- */
10
- export const testQuick = () => {
11
- let testPath = gulpConfig.get('test.path')
12
- if (!Array.isArray(testPath)) {
13
- // The testPath must be an array of strings
14
- testPath = [testPath]
15
- }
16
- return runCLI({ onlyChanged: true }, testPath)
17
- }
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { runCLI } from 'jest'
3
+
4
+ /**
5
+ * Run the Jest tests for files which have been modified (based on git status).
6
+ * Configure where tests are located by using 'testPath'.
7
+ * @memberOf module:js-build-tools
8
+ * @returns {Promise<*>}
9
+ */
10
+ export const testQuick = () => {
11
+ let testPath = gulpConfig.get('test.path')
12
+ if (!Array.isArray(testPath)) {
13
+ // The testPath must be an array of strings
14
+ testPath = [testPath]
15
+ }
16
+ return runCLI({ onlyChanged: true }, testPath)
17
+ }
@@ -1,17 +1,17 @@
1
- import { testHelpers } from './testHelpers.mjs'
2
- import { runCLI } from 'jest'
3
- import { testQuick } from './testQuick.mjs'
4
-
5
- const gulpConfig = testHelpers.gulpConfig
6
-
7
- jest.mock('jest', () => ({
8
- runCLI: jest.fn(() => Promise.resolve(true))
9
- }))
10
-
11
- describe('testQuick', () => {
12
- test('runs the jest CLI with onlyChanged option', () => {
13
- expect.assertions(1)
14
- testQuick()
15
- expect(runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('test.path')])
16
- })
17
- })
1
+ import { testHelpers } from './testHelpers.mjs'
2
+ import { runCLI } from 'jest'
3
+ import { testQuick } from './testQuick.mjs'
4
+
5
+ const gulpConfig = testHelpers.gulpConfig
6
+
7
+ jest.mock('jest', () => ({
8
+ runCLI: jest.fn(() => Promise.resolve(true))
9
+ }))
10
+
11
+ describe('testQuick', () => {
12
+ test('runs the jest CLI with onlyChanged option', () => {
13
+ expect.assertions(1)
14
+ testQuick()
15
+ expect(runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('test.path')])
16
+ })
17
+ })
@@ -1,9 +1,9 @@
1
- import { typeDocsFor } from './partials/typeDocsFor.mjs'
2
-
3
- /**
4
- * Generate the HTML documentation of a TypeScript project from its source, with the modules mirroring the source
5
- * folders. Turn it on with docs.enabled, see {@link module:partials.typeDocsFor}.
6
- * @memberOf module:js-build-tools
7
- * @returns {Function}
8
- */
9
- export const typeDocs = typeDocsFor()
1
+ import { typeDocsFor } from './partials/typeDocsFor.mjs'
2
+
3
+ /**
4
+ * Generate the HTML documentation of a TypeScript project from its source, with the modules mirroring the source
5
+ * folders. Turn it on with docs.enabled, see {@link module:partials.typeDocsFor}.
6
+ * @memberOf module:js-build-tools
7
+ * @returns {Function}
8
+ */
9
+ export const typeDocs = typeDocsFor()
@@ -1,11 +1,11 @@
1
- import { typeDocs } from './typeDocs.mjs'
2
- import { typeDocsFor } from './partials/typeDocsFor.mjs'
3
-
4
- jest.mock('./partials/typeDocsFor.mjs', () => ({ typeDocsFor: jest.fn(() => () => null) }))
5
-
6
- describe('typeDocs', () => {
7
- test('is the task made by typeDocsFor with no parameters', () => {
8
- expect(typeDocsFor).toHaveBeenCalledWith()
9
- expect(typeDocs).toBeInstanceOf(Function)
10
- })
11
- })
1
+ import { typeDocs } from './typeDocs.mjs'
2
+ import { typeDocsFor } from './partials/typeDocsFor.mjs'
3
+
4
+ jest.mock('./partials/typeDocsFor.mjs', () => ({ typeDocsFor: jest.fn(() => () => null) }))
5
+
6
+ describe('typeDocs', () => {
7
+ test('is the task made by typeDocsFor with no parameters', () => {
8
+ expect(typeDocsFor).toHaveBeenCalledWith()
9
+ expect(typeDocs).toBeInstanceOf(Function)
10
+ })
11
+ })
@@ -1,8 +1,8 @@
1
- import { tsFor } from './partials/tsFor.mjs'
2
-
3
- /**
4
- * Simplified typescript task using tsFor.
5
- * @memberOf module:js-build-tools
6
- * @returns {Function}
7
- */
8
- export const typeScript = tsFor()
1
+ import { tsFor } from './partials/tsFor.mjs'
2
+
3
+ /**
4
+ * Simplified typescript task using tsFor.
5
+ * @memberOf module:js-build-tools
6
+ * @returns {Function}
7
+ */
8
+ export const typeScript = tsFor()
@@ -1,11 +1,11 @@
1
- import { typeScript } from './typeScript.mjs'
2
- import { tsFor } from './partials/tsFor.mjs'
3
-
4
- jest.mock('./partials/tsFor.mjs', () => ({ tsFor: jest.fn(() => () => null) }))
5
-
6
- describe('typeScript', () => {
7
- test('calls tsFor with no parameters', () => {
8
- typeScript()
9
- expect(tsFor).toHaveBeenCalled()
10
- })
11
- })
1
+ import { typeScript } from './typeScript.mjs'
2
+ import { tsFor } from './partials/tsFor.mjs'
3
+
4
+ jest.mock('./partials/tsFor.mjs', () => ({ tsFor: jest.fn(() => () => null) }))
5
+
6
+ describe('typeScript', () => {
7
+ test('calls tsFor with no parameters', () => {
8
+ typeScript()
9
+ expect(tsFor).toHaveBeenCalled()
10
+ })
11
+ })
@@ -1,34 +1,34 @@
1
- import fs from 'fs'
2
- import os from 'os'
3
- import path from 'path'
4
- import { esmNamedExportsToCjs } from './esmNamedExportsToCjs.mjs'
5
-
6
- /**
7
- * Writes a rewritten (see {@link esmNamedExportsToCjs}) copy of each given `.mjs` file into a fresh, unique
8
- * directory under the OS temp directory, with a `.js` extension - jsdoc-to-markdown only recognizes `.js` as a
9
- * documentable file, regardless of whether its contents are actually CommonJS or ESM (it parses the real ESM
10
- * syntax of the rest of a file fine; the extension is the only thing it filters on). Writing outside the project
11
- * tree means there is nothing to gitignore and nothing left behind in the project - call the returned `cleanUp`
12
- * once done (for example, right after jsdoc-to-markdown has read the files) to remove the temp directory.
13
- * @memberOf module:utilities
14
- * @param {Array<string>} mjsFilePaths - Real `.mjs` files to convert. An empty array is a safe, cheap no-op.
15
- * @returns {{filePaths: Array<string>, cleanUp: function(): void}} The temp `.js` file paths to pass to
16
- * jsdoc-to-markdown instead of the real `.mjs` ones, and a function to remove the temp directory afterward.
17
- * @private
18
- */
19
- export const convertMjsFilesForDocs = (mjsFilePaths = []) => {
20
- if (mjsFilePaths.length === 0) {
21
- return { filePaths: [], cleanUp: () => {} }
22
- }
23
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'js-build-tools-docs-'))
24
- const filePaths = mjsFilePaths.map((mjsFilePath) => {
25
- const tempFilePath = path.join(tempDir, path.basename(mjsFilePath, '.mjs') + '.js')
26
- const source = fs.readFileSync(mjsFilePath, 'utf8')
27
- fs.writeFileSync(tempFilePath, esmNamedExportsToCjs(source))
28
- return tempFilePath
29
- })
30
- return {
31
- filePaths,
32
- cleanUp: () => fs.rmSync(tempDir, { recursive: true, force: true })
33
- }
34
- }
1
+ import fs from 'fs'
2
+ import os from 'os'
3
+ import path from 'path'
4
+ import { esmNamedExportsToCjs } from './esmNamedExportsToCjs.mjs'
5
+
6
+ /**
7
+ * Writes a rewritten (see {@link esmNamedExportsToCjs}) copy of each given `.mjs` file into a fresh, unique
8
+ * directory under the OS temp directory, with a `.js` extension - jsdoc-to-markdown only recognizes `.js` as a
9
+ * documentable file, regardless of whether its contents are actually CommonJS or ESM (it parses the real ESM
10
+ * syntax of the rest of a file fine; the extension is the only thing it filters on). Writing outside the project
11
+ * tree means there is nothing to gitignore and nothing left behind in the project - call the returned `cleanUp`
12
+ * once done (for example, right after jsdoc-to-markdown has read the files) to remove the temp directory.
13
+ * @memberOf module:utilities
14
+ * @param {Array<string>} mjsFilePaths - Real `.mjs` files to convert. An empty array is a safe, cheap no-op.
15
+ * @returns {{filePaths: Array<string>, cleanUp: function(): void}} The temp `.js` file paths to pass to
16
+ * jsdoc-to-markdown instead of the real `.mjs` ones, and a function to remove the temp directory afterward.
17
+ * @private
18
+ */
19
+ export const convertMjsFilesForDocs = (mjsFilePaths = []) => {
20
+ if (mjsFilePaths.length === 0) {
21
+ return { filePaths: [], cleanUp: () => {} }
22
+ }
23
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'js-build-tools-docs-'))
24
+ const filePaths = mjsFilePaths.map((mjsFilePath) => {
25
+ const tempFilePath = path.join(tempDir, path.basename(mjsFilePath, '.mjs') + '.js')
26
+ const source = fs.readFileSync(mjsFilePath, 'utf8')
27
+ fs.writeFileSync(tempFilePath, esmNamedExportsToCjs(source))
28
+ return tempFilePath
29
+ })
30
+ return {
31
+ filePaths,
32
+ cleanUp: () => fs.rmSync(tempDir, { recursive: true, force: true })
33
+ }
34
+ }