js-build-tools 3.0.3 → 4.0.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 (213) hide show
  1. package/README.md +431 -691
  2. package/babel.config.js +1 -1
  3. package/dist/build.js +58 -59
  4. package/dist/build.min.js +1 -1
  5. package/dist/bundle.js +17 -12
  6. package/dist/bundle.min.js +1 -1
  7. package/dist/bundleLint.js +21 -17
  8. package/dist/bundleLint.min.js +1 -1
  9. package/dist/bundleMinify.js +14 -8
  10. package/dist/bundleMinify.min.js +1 -1
  11. package/dist/compileReadme.js +10 -13
  12. package/dist/compileReadme.min.js +1 -1
  13. package/dist/copyFonts.js +14 -8
  14. package/dist/copyFonts.min.js +1 -1
  15. package/dist/default.js +19 -15
  16. package/dist/default.min.js +1 -1
  17. package/dist/dist.js +10 -7
  18. package/dist/dist.min.js +1 -1
  19. package/dist/distLint.js +21 -17
  20. package/dist/distLint.min.js +1 -1
  21. package/dist/distMinify.js +14 -8
  22. package/dist/distMinify.min.js +1 -1
  23. package/dist/images.js +10 -7
  24. package/dist/images.min.js +1 -1
  25. package/dist/partials/addToReadme.js +19 -14
  26. package/dist/partials/beginWatcher.js +14 -10
  27. package/dist/partials/clean.js +17 -11
  28. package/dist/partials/copyFor.js +10 -10
  29. package/dist/partials/distFor.js +27 -17
  30. package/dist/partials/distForSrc.js +16 -10
  31. package/dist/partials/distSeries.js +24 -20
  32. package/dist/partials/imagesFor.js +27 -28
  33. package/dist/partials/minifyFor.js +17 -16
  34. package/dist/partials/readmeTemplate.js +16 -12
  35. package/dist/partials/removeDirectory.js +12 -12
  36. package/dist/partials/runOnChange.js +30 -28
  37. package/dist/partials/sassFor.js +28 -21
  38. package/dist/partials/tsFor.js +24 -21
  39. package/dist/partials.js +103 -41
  40. package/dist/partials.min.js +1 -1
  41. package/dist/sass.js +10 -7
  42. package/dist/sass.min.js +1 -1
  43. package/dist/test-helpers/setUp.js +68 -65
  44. package/dist/testFull.js +22 -17
  45. package/dist/testFull.min.js +1 -1
  46. package/dist/testHelpers.js +11 -15
  47. package/dist/testHelpers.min.js +1 -1
  48. package/dist/testQuick.js +24 -19
  49. package/dist/testQuick.min.js +1 -1
  50. package/dist/typeScript.js +9 -7
  51. package/dist/typeScript.min.js +1 -1
  52. package/dist/utilities/dotGet.js +45 -43
  53. package/dist/utilities/dotNotate.js +53 -51
  54. package/dist/utilities/dotSet.js +39 -37
  55. package/dist/utilities/isObject.js +9 -5
  56. package/dist/utilities/strAfter.js +18 -14
  57. package/dist/utilities/strBefore.js +18 -14
  58. package/dist/watchFull.js +10 -10
  59. package/dist/watchFull.min.js +1 -1
  60. package/dist/watchTest.js +17 -13
  61. package/dist/watchTest.min.js +1 -1
  62. package/functions/{build.js → build.mjs} +14 -16
  63. package/functions/{build.test.js → build.test.mjs} +9 -8
  64. package/functions/{bundle.js → bundle.mjs} +5 -7
  65. package/functions/{bundle.test.js → bundle.test.mjs} +5 -4
  66. package/functions/{bundleLint.js → bundleLint.mjs} +4 -6
  67. package/functions/{bundleLint.test.js → bundleLint.test.mjs} +5 -4
  68. package/functions/bundleMinify.mjs +9 -0
  69. package/functions/bundleMinify.test.mjs +15 -0
  70. package/functions/compileReadme.mjs +9 -0
  71. package/functions/{compileReadme.test.js → compileReadme.test.mjs} +4 -4
  72. package/functions/copyFonts.mjs +9 -0
  73. package/functions/{copyFonts.test.js → copyFonts.test.mjs} +4 -3
  74. package/functions/default.mjs +12 -0
  75. package/functions/{default.test.js → default.test.mjs} +8 -7
  76. package/functions/{dist.js → dist.mjs} +2 -4
  77. package/functions/{dist.test.js → dist.test.mjs} +4 -3
  78. package/functions/{distLint.js → distLint.mjs} +4 -6
  79. package/functions/{distLint.test.js → distLint.test.mjs} +5 -4
  80. package/functions/distMinify.mjs +9 -0
  81. package/functions/distMinify.test.mjs +15 -0
  82. package/functions/{images.js → images.mjs} +2 -4
  83. package/functions/{images.test.js → images.test.mjs} +4 -3
  84. package/functions/partials/{addToReadme.js → addToReadme.mjs} +5 -7
  85. package/functions/partials/{addToReadme.test.js → addToReadme.test.mjs} +4 -3
  86. package/functions/partials/beginWatcher.mjs +9 -0
  87. package/functions/partials/{beginWatcher.test.js → beginWatcher.test.mjs} +4 -3
  88. package/functions/partials/clean.mjs +13 -0
  89. package/functions/partials/{clean.test.js → clean.test.mjs} +4 -3
  90. package/functions/partials/{copyFor.js → copyFor.mjs} +2 -4
  91. package/functions/partials/{copyFor.test.js → copyFor.test.mjs} +4 -3
  92. package/functions/partials/distFor.mjs +22 -0
  93. package/functions/partials/{distFor.test.js → distFor.test.mjs} +49 -8
  94. package/functions/partials/{distForSrc.js → distForSrc.mjs} +2 -4
  95. package/functions/partials/{distForSrc.test.js → distForSrc.test.mjs} +3 -2
  96. package/functions/partials/{distSeries.js → distSeries.mjs} +6 -8
  97. package/functions/partials/{distSeries.test.js → distSeries.test.mjs} +7 -6
  98. package/functions/partials/{imagesFor.js → imagesFor.mjs} +5 -13
  99. package/functions/partials/{imagesFor.test.js → imagesFor.test.mjs} +4 -3
  100. package/functions/partials/minifyFor.mjs +15 -0
  101. package/functions/partials/{minifyFor.test.js → minifyFor.test.mjs} +5 -4
  102. package/functions/partials/readmeTemplate.mjs +12 -0
  103. package/functions/partials/{readmeTemplate.test.js → readmeTemplate.test.mjs} +4 -3
  104. package/functions/partials/{removeDirectory.js → removeDirectory.mjs} +2 -4
  105. package/functions/partials/{removeDirectory.test.js → removeDirectory.test.mjs} +28 -28
  106. package/functions/partials/{runOnChange.js → runOnChange.mjs} +6 -8
  107. package/functions/partials/{runOnChange.test.js → runOnChange.test.mjs} +12 -11
  108. package/functions/partials/sassFor.mjs +22 -0
  109. package/functions/partials/{sassFor.test.js → sassFor.test.mjs} +5 -4
  110. package/functions/partials/{tsFor.js → tsFor.mjs} +4 -6
  111. package/functions/partials/{tsFor.test.js → tsFor.test.mjs} +5 -4
  112. package/functions/partials.mjs +23 -0
  113. package/functions/{partials.test.js → partials.test.mjs} +1 -1
  114. package/functions/sass.mjs +4 -0
  115. package/functions/{sass.test.js → sass.test.mjs} +4 -3
  116. package/functions/test-helpers/{setUp.js → setUp.mjs} +25 -27
  117. package/functions/test-helpers/setUp.test.mjs +19 -0
  118. package/functions/{testFull.js → testFull.mjs} +4 -6
  119. package/functions/testFull.test.mjs +17 -0
  120. package/functions/{testHelpers.js → testHelpers.mjs} +1 -6
  121. package/functions/testHelpers.test.mjs +7 -0
  122. package/functions/{testQuick.js → testQuick.mjs} +4 -6
  123. package/functions/testQuick.test.mjs +17 -0
  124. package/functions/{typeScript.js → typeScript.mjs} +2 -4
  125. package/functions/typeScript.test.mjs +11 -0
  126. package/functions/utilities/{dotGet.js → dotGet.mjs} +4 -6
  127. package/functions/utilities/{dotNotate.js → dotNotate.mjs} +2 -4
  128. package/functions/utilities/{dotSet.js → dotSet.mjs} +4 -6
  129. package/functions/utilities/{isObject.js → isObject.mjs} +1 -3
  130. package/functions/utilities/{strAfter.js → strAfter.mjs} +11 -13
  131. package/functions/utilities/{strBefore.js → strBefore.mjs} +11 -13
  132. package/functions/{watchFull.js → watchFull.mjs} +2 -4
  133. package/functions/{watchFull.test.js → watchFull.test.mjs} +8 -7
  134. package/functions/watchTest.mjs +10 -0
  135. package/functions/{watchTest.test.js → watchTest.test.mjs} +7 -6
  136. package/gulp.config.js +20 -19
  137. package/gulp.config.mjs +252 -0
  138. package/gulpfile.base.js +20 -20
  139. package/gulpfile.base.mjs +27 -0
  140. package/package.json +20 -14
  141. package/functions/bundleMinify.js +0 -11
  142. package/functions/bundleMinify.test.js +0 -14
  143. package/functions/compileReadme.js +0 -11
  144. package/functions/copyFonts.js +0 -11
  145. package/functions/default.js +0 -14
  146. package/functions/distMinify.js +0 -11
  147. package/functions/distMinify.test.js +0 -14
  148. package/functions/partials/beginWatcher.js +0 -11
  149. package/functions/partials/clean.js +0 -15
  150. package/functions/partials/distFor.js +0 -17
  151. package/functions/partials/minifyFor.js +0 -15
  152. package/functions/partials/readmeTemplate.js +0 -14
  153. package/functions/partials/sassFor.js +0 -21
  154. package/functions/partials.js +0 -40
  155. package/functions/sass.js +0 -6
  156. package/functions/test-helpers/setUp.test.js +0 -18
  157. package/functions/testFull.test.js +0 -16
  158. package/functions/testHelpers.test.js +0 -7
  159. package/functions/testQuick.test.js +0 -16
  160. package/functions/typeScript.test.js +0 -10
  161. package/functions/watchTest.js +0 -12
  162. package/vendor/array-union/index.js +0 -31
  163. package/vendor/easy-transform-stream/index.js +0 -54
  164. package/vendor/globby/gitignore.js +0 -96
  165. package/vendor/globby/index.js +0 -191
  166. package/vendor/globby/node_modules/slash/index.js +0 -16
  167. package/vendor/globby/stream-utils.js +0 -58
  168. package/vendor/globby/to-path.js +0 -20
  169. package/vendor/gulp-imagemin/index.js +0 -124
  170. package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +0 -265
  171. package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +0 -36
  172. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
  173. package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
  174. package/vendor/gulp-plugin-extras/index.js +0 -42
  175. package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +0 -265
  176. package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +0 -36
  177. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -217
  178. package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +0 -154
  179. package/vendor/gulp-plugin-extras/plugin-error.js +0 -145
  180. package/vendor/ignore/index.js +0 -468
  181. package/vendor/imagemin/index.js +0 -90
  182. package/vendor/imagemin-gifsicle/index.js +0 -33
  183. package/vendor/imagemin-mozjpeg/index.js +0 -100
  184. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +0 -260
  185. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +0 -47
  186. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +0 -102
  187. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +0 -123
  188. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +0 -47
  189. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +0 -50
  190. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +0 -124
  191. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +0 -238
  192. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +0 -89
  193. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +0 -24
  194. package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +0 -44
  195. package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +0 -25
  196. package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +0 -70
  197. package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +0 -52
  198. package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +0 -43
  199. package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +0 -20
  200. package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +0 -17
  201. package/vendor/imagemin-optipng/index.js +0 -44
  202. package/vendor/imagemin-svgo/index.js +0 -27
  203. package/vendor/is-jpg/index.js +0 -12
  204. package/vendor/junk/index.js +0 -49
  205. package/vendor/mozjpeg/index.js +0 -9
  206. package/vendor/mozjpeg/lib/index.js +0 -18
  207. package/vendor/mozjpeg/package.json +0 -49
  208. package/vendor/mozjpeg/vendor/cjpeg +0 -0
  209. package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
  210. package/vendor/p-pipe/index.js +0 -22
  211. package/vendor/plur/index.js +0 -32
  212. package/vendor/pretty-bytes/index.js +0 -71
  213. package/vendor/slash/index.js +0 -12
@@ -1,28 +1,28 @@
1
- const fs = require('fs')
2
- const removeDirectory = require('./removeDirectory')
3
-
4
- describe('removeDirectory', () => {
5
- test('able to delete the remove-directory', async () => {
6
- const dirPath = 'remove-directory'
7
- fs.mkdirSync(dirPath)
8
- expect(fs.existsSync(dirPath)).toBeTruthy()
9
- await removeDirectory(dirPath)
10
- expect(fs.existsSync(dirPath)).toBeFalsy()
11
- })
12
-
13
- test('able to delete directory with sub-directories', async () => {
14
- const dirPath = 'remove-directory'
15
- fs.mkdirSync(dirPath)
16
- const subDir = `${dirPath}/sub`
17
- fs.mkdirSync(subDir)
18
- expect(fs.existsSync(subDir)).toBeTruthy()
19
- await removeDirectory(dirPath)
20
- expect(fs.existsSync(subDir)).toBeFalsy()
21
- })
22
-
23
- test('ends cleanly if directory does not exist', async () => {
24
- const dirPath = 'remove-directory'
25
- expect(fs.existsSync(dirPath)).toBeFalsy()
26
- expect(await removeDirectory(dirPath)).toBe(dirPath)
27
- })
28
- })
1
+ import fs from 'fs'
2
+ import { removeDirectory } from './removeDirectory.mjs'
3
+
4
+ describe('removeDirectory', () => {
5
+ test('able to delete the remove-directory', async () => {
6
+ const dirPath = 'remove-directory'
7
+ fs.mkdirSync(dirPath)
8
+ expect(fs.existsSync(dirPath)).toBeTruthy()
9
+ await removeDirectory(dirPath)
10
+ expect(fs.existsSync(dirPath)).toBeFalsy()
11
+ })
12
+
13
+ test('able to delete directory with sub-directories', async () => {
14
+ const dirPath = 'remove-directory'
15
+ fs.mkdirSync(dirPath)
16
+ const subDir = `${dirPath}/sub`
17
+ fs.mkdirSync(subDir)
18
+ expect(fs.existsSync(subDir)).toBeTruthy()
19
+ await removeDirectory(dirPath)
20
+ expect(fs.existsSync(subDir)).toBeFalsy()
21
+ })
22
+
23
+ test('ends cleanly if directory does not exist', async () => {
24
+ const dirPath = 'remove-directory'
25
+ expect(fs.existsSync(dirPath)).toBeFalsy()
26
+ expect(await removeDirectory(dirPath)).toBe(dirPath)
27
+ })
28
+ })
@@ -1,8 +1,8 @@
1
- const gulpConfig = require('../../gulp.config.js')
2
- const bundle = require('../bundle')
3
- const distSeries = require('./distSeries')
4
- const { parallel, series } = require('gulp')
5
- const testQuick = require('../testQuick')
1
+ import * as gulpConfig from '../../gulp.config.mjs'
2
+ import { bundle } from '../bundle.mjs'
3
+ import { distSeries } from './distSeries.mjs'
4
+ import { parallel, series } from 'gulp'
5
+ import { testQuick } from '../testQuick.mjs'
6
6
 
7
7
  /**
8
8
  * Run this function when the watched files are modified.
@@ -29,7 +29,7 @@ const testQuick = require('../testQuick')
29
29
  * @param {string} path
30
30
  * @returns {stream.Stream}
31
31
  */
32
- const runOnChange = path => {
32
+ export const runOnChange = path => {
33
33
  const useTs = gulpConfig.get('typescript.enabled')
34
34
  const distPath = gulpConfig.get('dist.to')
35
35
  const srcPath = gulpConfig.get('srcPath')
@@ -52,5 +52,3 @@ const runOnChange = path => {
52
52
  ? parallel(testQuick, series(runSeries, bundle))()
53
53
  : series(testQuick, runSeries)()
54
54
  }
55
-
56
- module.exports = runOnChange
@@ -1,19 +1,20 @@
1
- const fs = require('fs')
2
- const setUp = require('../test-helpers/setUp')
1
+ import fs from 'fs'
2
+ import * as setUp from '../test-helpers/setUp.mjs'
3
+ import { bundle } from '../bundle.mjs'
4
+ import { distFor } from './distFor.mjs'
5
+ import { runOnChange } from './runOnChange.mjs'
6
+ import { tsFor } from './tsFor.mjs'
7
+ import { testQuick } from '../testQuick.mjs'
8
+
3
9
  setUp.setDefaults('test-run-on-change')
4
10
  const gulpConfig = setUp.gulpConfig
5
- const bundle = require('../bundle')
6
- const distFor = require('./distFor')
7
- const runOnChange = require('./runOnChange')
8
- const tsFor = require('./tsFor')
9
- const testQuick = require('../testQuick')
10
11
 
11
12
  const genericFunction = () => Promise.resolve(true)
12
13
 
13
- jest.mock('../bundle', () => jest.fn(genericFunction))
14
- jest.mock('./distFor', () => jest.fn(genericFunction))
15
- jest.mock('./tsFor', () => jest.fn(() => genericFunction))
16
- jest.mock('../testQuick', () => jest.fn(genericFunction))
14
+ jest.mock('../bundle.mjs', () => ({ bundle: jest.fn(genericFunction) }))
15
+ jest.mock('./distFor.mjs', () => ({ distFor: jest.fn(genericFunction) }))
16
+ jest.mock('./tsFor.mjs', () => ({ tsFor: jest.fn(() => genericFunction) }))
17
+ jest.mock('../testQuick.mjs', () => ({ testQuick: jest.fn(genericFunction) }))
17
18
 
18
19
  const rawContents = 'export function sayHello(name: string) {\n' +
19
20
  ' return `Hello from ${name}`;\n' +
@@ -0,0 +1,22 @@
1
+ import { dest, src } from 'gulp'
2
+ import * as gulpConfig from '../../gulp.config.mjs'
3
+ import cssnano from 'gulp-cssnano'
4
+ import rename from 'gulp-rename'
5
+ import * as sass from 'sass'
6
+ import { default as gulpSass } from 'gulp-sass'
7
+
8
+ const runSass = gulpSass(sass)
9
+
10
+ /**
11
+ * Build the CSS for a given source pattern.
12
+ * @memberOf module:partials
13
+ * @param {string|array} [srcSearch='src/config/path/sass/for']
14
+ * @param {string} [cssPath='css/config/path']
15
+ * @returns {stream.Stream}
16
+ */
17
+ export const sassFor = (srcSearch = gulpConfig.get('sass.from'), cssPath = gulpConfig.get('sass.to')) => src(srcSearch)
18
+ .pipe(runSass().on('error', runSass.logError)) // Passes it through a gulp-sass, log errors to console
19
+ .pipe(dest(cssPath))
20
+ .pipe(cssnano())
21
+ .pipe(rename({ extname: '.min.css' }))
22
+ .pipe(dest(cssPath))
@@ -1,9 +1,10 @@
1
- const fs = require('fs')
2
- const setUp = require('../test-helpers/setUp')
1
+ import fs from 'fs'
2
+ import * as setUp from '../test-helpers/setUp.mjs'
3
+ import { sassFor } from './sassFor.mjs'
4
+ import { countMatches } from 'test-filesystem'
5
+
3
6
  setUp.setDefaults('test-sass-for')
4
7
  const gulpConfig = setUp.gulpConfig
5
- const sassFor = require('./sassFor')
6
- const { countMatches } = require('test-filesystem')
7
8
 
8
9
  const sassContents = 'html\n' +
9
10
  ' font-size: 62.5%\n' +
@@ -1,6 +1,6 @@
1
- const { dest, parallel, src } = require('gulp')
2
- const gulpConfig = require('../../gulp.config.js')
3
- const ts = require('gulp-typescript')
1
+ import { dest, parallel, src } from 'gulp'
2
+ import * as gulpConfig from '../../gulp.config.mjs'
3
+ import ts from 'gulp-typescript'
4
4
 
5
5
  /**
6
6
  * Starting at the source directory, find all the ts files and convert them into the distribution directory.
@@ -10,12 +10,10 @@ const ts = require('gulp-typescript')
10
10
  * @returns {Function}
11
11
  * @see `https://www.typescriptlang.org/docs/handbook/gulp.html` for more info
12
12
  */
13
- const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to')) => {
13
+ export const tsFor = (srcPath = gulpConfig.get('typescript.from'), distPath = gulpConfig.get('typescript.to')) => {
14
14
  const declarationProject = ts.createProject(gulpConfig.get('typescript.config'))
15
15
  const tsProject = ts.createProject(gulpConfig.get('typescript.config'))
16
16
  const makeDeclarations = () => src(srcPath).pipe(declarationProject()).dts.pipe(dest(distPath))
17
17
  const compileJS = () => src(srcPath).pipe(tsProject()).js.pipe(dest(distPath))
18
18
  return parallel(makeDeclarations, compileJS)
19
19
  }
20
-
21
- module.exports = tsFor
@@ -1,9 +1,10 @@
1
- const fs = require('fs')
2
- const setUp = require('../test-helpers/setUp')
1
+ import fs from 'fs'
2
+ import * as setUp from '../test-helpers/setUp.mjs'
3
+ import { tsFor } from './tsFor.mjs'
4
+ import { countMatches } from 'test-filesystem'
5
+
3
6
  setUp.setDefaults('test-ts-for')
4
7
  const gulpConfig = setUp.gulpConfig
5
- const tsFor = require('./tsFor')
6
- const { countMatches } = require('test-filesystem')
7
8
 
8
9
  const rawContents = 'export function sayHello(name: string) {\n' +
9
10
  ' return `Hello from ${name}`;\n' +
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Micro-functions used as components for the main gulp functions.
3
+ * @file
4
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
5
+ * @version 3.0.0
6
+ * @module partials
7
+ * @memberOf module:js-build-tools
8
+ */
9
+
10
+ export { addToReadme } from './partials/addToReadme.mjs'
11
+ export { beginWatcher } from './partials/beginWatcher.mjs'
12
+ export { clean } from './partials/clean.mjs'
13
+ export { copyFor } from './partials/copyFor.mjs'
14
+ export { distFor } from './partials/distFor.mjs'
15
+ export { distForSrc } from './partials/distForSrc.mjs'
16
+ export { distSeries } from './partials/distSeries.mjs'
17
+ export { imagesFor } from './partials/imagesFor.mjs'
18
+ export { minifyFor } from './partials/minifyFor.mjs'
19
+ export { readmeTemplate } from './partials/readmeTemplate.mjs'
20
+ export { removeDirectory } from './partials/removeDirectory.mjs'
21
+ export { runOnChange } from './partials/runOnChange.mjs'
22
+ export { sassFor } from './partials/sassFor.mjs'
23
+ export { tsFor } from './partials/tsFor.mjs'
@@ -1,4 +1,4 @@
1
- const partials = require('./partials')
1
+ import * as partials from './partials.mjs'
2
2
 
3
3
  describe('partials', () => {
4
4
  test('is object with all partial exports', () => {
@@ -0,0 +1,4 @@
1
+ import { sassFor } from './partials/sassFor.mjs'
2
+
3
+ // Compile sass into CSS & auto-inject into browsers
4
+ export const sass = () => sassFor()
@@ -1,8 +1,9 @@
1
- const fs = require('fs')
2
- const setUp = require('./test-helpers/setUp')
1
+ import fs from 'fs'
2
+ import * as setUp from './test-helpers/setUp.mjs'
3
+ import { sass } from './sass.mjs'
4
+
3
5
  setUp.setDefaults('test-sass')
4
6
  const gulpConfig = setUp.gulpConfig
5
- const sass = require('./sass')
6
7
 
7
8
  beforeEach(() => setUp.beforeEach().then(
8
9
  () => {
@@ -1,6 +1,6 @@
1
1
  // Import the configurations and override some of them to direct to the temp directory.
2
- const gulpConfig = require('../../gulp.config.js')
3
- const { setUp } = require('test-filesystem')
2
+ import * as gulpConfig from '../../gulp.config.mjs'
3
+ import * as setUp from 'test-filesystem'
4
4
 
5
5
  let tempDir = 'test-temp/'
6
6
  let srcPath = `${tempDir}src`
@@ -10,7 +10,7 @@ let srcPath = `${tempDir}src`
10
10
  * @memberOf module:testHelpers
11
11
  * @param {string} testDir
12
12
  */
13
- const setDefaults = (testDir = 'test-temp') => {
13
+ export const setDefaults = (testDir = 'test-temp') => {
14
14
  tempDir = `${testDir}/`
15
15
  srcPath = `${tempDir}src`
16
16
  setUp.setDefaults(tempDir)
@@ -40,28 +40,26 @@ const setDefaults = (testDir = 'test-temp') => {
40
40
  gulpConfig.set('test.watch', `${srcPath}/**/*.js`)
41
41
  }
42
42
 
43
- exports.setDefaults = setDefaults
43
+ export { gulpConfig, setUp }
44
44
 
45
- exports.gulpConfig = gulpConfig
46
-
47
- /**
48
- * Ensure that the del has completed, recursively attempt to delete and recreate
49
- * @memberOf module:testHelpers
50
- * @param {boolean} [exists=true]
51
- * @returns {Promise<*|void>}
52
- */
53
- exports.createTempDir = setUp.createTempDir
54
-
55
- /**
56
- * In the Jest.beforeEach function call this one to set up the temp directory.
57
- * @memberOf module:testHelpers
58
- * @returns {Promise<*|void>}
59
- */
60
- exports.beforeEach = setUp.beforeEach
61
-
62
- /**
63
- * In the Jest.afterEach function call this one to clean up and remove the temp directory.
64
- * @memberOf module:testHelpers
65
- * @returns {Promise<*>}
66
- */
67
- exports.afterEach = setUp.afterEach
45
+ export {
46
+ /**
47
+ * Ensure that the del has completed, recursively attempt to delete and recreate
48
+ * @memberOf module:testHelpers
49
+ * @param {boolean} [exists=true]
50
+ * @returns {Promise<*|void>}
51
+ */
52
+ createTempDir,
53
+ /**
54
+ * In the Jest.beforeEach function call this one to set up the temp directory.
55
+ * @memberOf module:testHelpers
56
+ * @returns {Promise<*|void>}
57
+ */
58
+ beforeEach,
59
+ /**
60
+ * In the Jest.afterEach function call this one to clean up and remove the temp directory.
61
+ * @memberOf module:testHelpers
62
+ * @returns {Promise<*>}
63
+ */
64
+ afterEach
65
+ } from 'test-filesystem'
@@ -0,0 +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,5 +1,5 @@
1
- const gulpConfig = require('../gulp.config.js')
2
- const { runCLI } = require('jest')
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { default as jest } from 'jest'
3
3
 
4
4
  /**
5
5
  * Run all tests with jest.
@@ -7,13 +7,11 @@ const { runCLI } = require('jest')
7
7
  * @memberOf module:js-build-tools
8
8
  * @returns {Promise<*>}
9
9
  */
10
- const testFull = () => {
10
+ export const testFull = () => {
11
11
  let testPath = gulpConfig.get('test.path')
12
12
  if (!Array.isArray(testPath)) {
13
13
  // The testPath must be an array of strings
14
14
  testPath = [testPath]
15
15
  }
16
- return runCLI(gulpConfig.get('test.options'), testPath)
16
+ return jest.runCLI(gulpConfig.get('test.options'), testPath)
17
17
  }
18
-
19
- module.exports = testFull
@@ -0,0 +1,17 @@
1
+ import { testHelpers } from './testHelpers.mjs'
2
+ import { default as jestImport } 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(jestImport.runCLI).toHaveBeenCalledWith(gulpConfig.get('test.options'), [gulpConfig.get('test.path')])
16
+ })
17
+ })
@@ -7,9 +7,4 @@
7
7
  * @memberOf module:js-build-tools
8
8
  */
9
9
 
10
-
11
- const setUp = require('./test-helpers/setUp')
12
-
13
- module.exports = {
14
- setUp,
15
- }
10
+ export * as testHelpers from './test-helpers/setUp.mjs'
@@ -0,0 +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(6)
6
+ })
7
+ })
@@ -1,5 +1,5 @@
1
- const gulpConfig = require('../gulp.config.js')
2
- const { runCLI } = require('jest')
1
+ import * as gulpConfig from '../gulp.config.mjs'
2
+ import { default as jest } from 'jest'
3
3
 
4
4
  /**
5
5
  * Run the Jest tests for files which have been modified (based on git status).
@@ -7,13 +7,11 @@ const { runCLI } = require('jest')
7
7
  * @memberOf module:js-build-tools
8
8
  * @returns {Promise<*>}
9
9
  */
10
- const testQuick = () => {
10
+ export const testQuick = () => {
11
11
  let testPath = gulpConfig.get('test.path')
12
12
  if (!Array.isArray(testPath)) {
13
13
  // The testPath must be an array of strings
14
14
  testPath = [testPath]
15
15
  }
16
- return runCLI({ onlyChanged: true }, testPath)
16
+ return jest.runCLI({ onlyChanged: true }, testPath)
17
17
  }
18
-
19
- module.exports = testQuick
@@ -0,0 +1,17 @@
1
+ import { testHelpers } from './testHelpers.mjs'
2
+ import { default as jestImport } 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(jestImport.runCLI).toHaveBeenCalledWith({ onlyChanged: true }, [gulpConfig.get('test.path')])
16
+ })
17
+ })
@@ -1,10 +1,8 @@
1
- const tsFor = require('./partials/tsFor')
1
+ import { tsFor } from './partials/tsFor.mjs'
2
2
 
3
3
  /**
4
4
  * Simplified typescript task using tsFor.
5
5
  * @memberOf module:js-build-tools
6
6
  * @returns {Function}
7
7
  */
8
- const typeScript = tsFor()
9
-
10
- module.exports = typeScript
8
+ export const typeScript = tsFor()
@@ -0,0 +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,6 +1,6 @@
1
- const isObject = require('./isObject')
2
- const strAfter = require('./strAfter')
3
- const strBefore = require('./strBefore')
1
+ import { isObject } from './isObject.mjs'
2
+ import { strAfter } from './strAfter.mjs'
3
+ import { strBefore } from './strBefore.mjs'
4
4
 
5
5
  /**
6
6
  * Get a nested property value from an object.
@@ -10,7 +10,7 @@ const strBefore = require('./strBefore')
10
10
  * @param {string|null} [defaultValue=null] - The default value to return if the property is not found
11
11
  * @returns {*} The value of the property
12
12
  */
13
- const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
13
+ export const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
14
14
  let key = strBefore(dotNotation, '.')
15
15
  const lastKey = !key
16
16
  if (lastKey) {
@@ -43,5 +43,3 @@ const dotGet = (arrayObject, dotNotation, defaultValue = null) => {
43
43
  }
44
44
  return dotGet(next, strAfter(dotNotation, '.'), defaultValue)
45
45
  }
46
-
47
- module.exports = dotGet
@@ -1,4 +1,4 @@
1
- const isObject = require('./isObject')
1
+ import { isObject } from './isObject.mjs'
2
2
 
3
3
  /**
4
4
  * Convert an array of keys into a regex, return a function to test if incoming keys match.
@@ -63,6 +63,4 @@ const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) =>
63
63
  * @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
64
64
  * @returns {Object<string, *>} The dot-notated object
65
65
  */
66
- const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
67
-
68
- module.exports = dotNotate
66
+ export const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects))
@@ -1,6 +1,6 @@
1
- const isObject = require('./isObject')
2
- const strAfter = require('./strAfter')
3
- const strBefore = require('./strBefore')
1
+ import { isObject } from './isObject.mjs'
2
+ import { strAfter } from './strAfter.mjs'
3
+ import { strBefore } from './strBefore.mjs'
4
4
 
5
5
  /**
6
6
  * Set a nested property value an object.
@@ -10,7 +10,7 @@ const strBefore = require('./strBefore')
10
10
  * @param {*} value - The default value to return if the property is not found
11
11
  * @returns {Object} The modified object
12
12
  */
13
- const dotSet = (arrayObject, dotNotation, value = null) => {
13
+ export const dotSet = (arrayObject, dotNotation, value = null) => {
14
14
  let key = strBefore(dotNotation, '.')
15
15
  const lastKey = !key
16
16
  if (lastKey) {
@@ -37,5 +37,3 @@ const dotSet = (arrayObject, dotNotation, value = null) => {
37
37
  arrayObject[key] = dotSet(next, strAfter(dotNotation, '.'), value)
38
38
  return arrayObject
39
39
  }
40
-
41
- module.exports = dotSet
@@ -4,6 +4,4 @@
4
4
  * @param {*} object
5
5
  * @returns {boolean}
6
6
  */
7
- const isObject = (object) => typeof object === 'object' && object !== null
8
-
9
- module.exports = isObject
7
+ export const isObject = (object) => typeof object === 'object' && object !== null
@@ -1,13 +1,11 @@
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
- */
8
- const strAfter = (str, search) => {
9
- const index = str.indexOf(search)
10
- return index === -1 ? '' : str.substring(index + search.length)
11
- }
12
-
13
- module.exports = strAfter
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
+ */
8
+ export const strAfter = (str, search) => {
9
+ const index = str.indexOf(search)
10
+ return index === -1 ? '' : str.substring(index + search.length)
11
+ }
@@ -1,13 +1,11 @@
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
- */
8
- const strBefore = (str, search) => {
9
- const index = str.indexOf(search)
10
- return index === -1 ? '' : str.slice(0, index)
11
- }
12
-
13
- module.exports = strBefore
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
+ */
8
+ export const strBefore = (str, search) => {
9
+ const index = str.indexOf(search)
10
+ return index === -1 ? '' : str.slice(0, index)
11
+ }
@@ -1,11 +1,9 @@
1
- const { beginWatcher, runOnChange } = require('./partials')
1
+ import { beginWatcher, runOnChange } from './partials.mjs'
2
2
 
3
3
  /**
4
4
  * Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
5
5
  * @memberOf module:js-build-tools
6
6
  * @returns {FSWatcher}
7
7
  */
8
- const watchFull = () => beginWatcher()
8
+ export const watchFull = () => beginWatcher()
9
9
  .on('change', runOnChange)
10
-
11
- module.exports = watchFull
@@ -1,13 +1,14 @@
1
- const fs = require('fs')
2
- const setUp = require('./test-helpers/setUp')
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
+
3
7
  setUp.setDefaults('test-watch-full')
4
8
  const gulpConfig = setUp.gulpConfig
5
- const watchFull = require('./watchFull')
6
- const beginWatcher = require('./partials/beginWatcher')
7
- const runOnChange = require('./partials/runOnChange')
8
9
 
9
- jest.mock('./partials/beginWatcher', () => jest.fn(() => ({ on: (event, fn) => fn() })))
10
- jest.mock('./partials/runOnChange', () => jest.fn())
10
+ jest.mock('./partials/beginWatcher.mjs', () => ({ beginWatcher: jest.fn(() => ({ on: (event, fn) => fn() })) }))
11
+ jest.mock('./partials/runOnChange.mjs', () => ({ runOnChange: jest.fn() }))
11
12
 
12
13
  const rawContents = 'const { beginWatcher, runOnChange } = require(\'./partials\')\n' +
13
14
  '\n' +