js-build-tools 2.3.1 → 3.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.
- package/README.md +334 -205
- package/dist/build.js +16 -5
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +12 -13
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +17 -18
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +8 -9
- package/dist/bundleMinify.min.js +1 -1
- package/dist/copyFonts.js +12 -0
- package/dist/copyFonts.min.js +1 -0
- package/dist/default.js +15 -15
- package/dist/default.min.js +1 -1
- package/dist/dist.js +0 -1
- package/dist/distLint.js +17 -18
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +8 -9
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +11 -0
- package/dist/images.min.js +1 -0
- package/dist/partials/addToReadme.js +13 -14
- package/dist/partials/beginWatcher.js +9 -10
- package/dist/partials/clean.js +0 -1
- package/dist/partials/copyFor.js +16 -0
- package/dist/partials/distFor.js +16 -17
- package/dist/partials/distForSrc.js +9 -10
- package/dist/partials/distSeries.js +19 -20
- package/dist/partials/imagesFor.js +34 -0
- package/dist/partials/minifyFor.js +0 -1
- package/dist/partials/readmeTemplate.js +11 -12
- package/dist/partials/removeDirectory.js +5 -6
- package/dist/partials/runOnChange.js +27 -27
- package/dist/partials/sassFor.js +2 -3
- package/dist/partials/tsFor.js +20 -21
- package/dist/partials.js +5 -1
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -7
- package/dist/test-helpers/setUp.js +31 -39
- package/dist/testFull.js +17 -18
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +10 -28
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +19 -20
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +0 -1
- package/dist/utilities/dotGet.js +50 -0
- package/dist/utilities/dotNotate.js +77 -0
- package/dist/utilities/dotSet.js +44 -0
- package/dist/utilities/isObject.js +10 -0
- package/dist/watchFull.js +0 -1
- package/dist/watchTest.js +13 -14
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +15 -5
- package/functions/build.test.js +278 -42
- package/functions/bundle.js +3 -4
- package/functions/bundle.test.js +6 -6
- package/functions/bundleLint.js +2 -3
- package/functions/bundleLint.test.js +5 -5
- package/functions/bundleMinify.js +1 -2
- package/functions/bundleMinify.test.js +1 -1
- package/functions/copyFonts.js +11 -0
- package/functions/copyFonts.test.js +31 -0
- package/functions/default.js +1 -1
- package/functions/default.test.js +2 -2
- package/functions/dist.js +0 -1
- package/functions/dist.test.js +1 -1
- package/functions/distLint.js +2 -3
- package/functions/distLint.test.js +3 -3
- package/functions/distMinify.js +1 -2
- package/functions/distMinify.test.js +1 -1
- package/functions/images.js +10 -0
- package/functions/images.test.js +138 -0
- package/functions/partials/addToReadme.js +2 -3
- package/functions/partials/addToReadme.test.js +2 -2
- package/functions/partials/beginWatcher.js +1 -2
- package/functions/partials/beginWatcher.test.js +1 -1
- package/functions/partials/clean.js +0 -1
- package/functions/partials/copyFor.js +13 -0
- package/functions/partials/copyFor.test.js +34 -0
- package/functions/partials/distFor.js +1 -2
- package/functions/partials/distFor.test.js +4 -4
- package/functions/partials/distForSrc.js +3 -4
- package/functions/partials/distForSrc.test.js +6 -6
- package/functions/partials/distSeries.js +2 -3
- package/functions/partials/distSeries.test.js +5 -5
- package/functions/partials/imagesFor.js +33 -0
- package/functions/partials/imagesFor.test.js +143 -0
- package/functions/partials/minifyFor.js +0 -1
- package/functions/partials/minifyFor.test.js +1 -1
- package/functions/partials/readmeTemplate.js +3 -4
- package/functions/partials/readmeTemplate.test.js +2 -2
- package/functions/partials/removeDirectory.js +22 -23
- package/functions/partials/runOnChange.js +5 -6
- package/functions/partials/runOnChange.test.js +9 -9
- package/functions/partials/sassFor.js +1 -2
- package/functions/partials/sassFor.test.js +3 -3
- package/functions/partials/tsFor.js +3 -4
- package/functions/partials/tsFor.test.js +2 -2
- package/functions/partials.js +5 -1
- package/functions/partials.test.js +1 -1
- package/functions/sass.test.js +2 -2
- package/functions/test-helpers/setUp.js +24 -32
- package/functions/testFull.js +2 -3
- package/functions/testFull.test.js +1 -1
- package/functions/testHelpers.js +3 -20
- package/functions/testHelpers.test.js +1 -1
- package/functions/testQuick.js +1 -2
- package/functions/testQuick.test.js +1 -1
- package/functions/typeScript.js +0 -1
- package/functions/typeScript.test.js +0 -2
- package/functions/utilities/dotGet.js +47 -0
- package/functions/utilities/dotNotate.js +68 -0
- package/functions/utilities/dotSet.js +41 -0
- package/functions/utilities/isObject.js +9 -0
- package/functions/watchFull.js +0 -1
- package/functions/watchFull.test.js +1 -1
- package/functions/watchTest.js +1 -2
- package/functions/watchTest.test.js +1 -1
- package/gulp.config.js +153 -79
- package/gulpfile.base.js +5 -1
- package/jsdoc.base.js +1 -1
- package/package.json +13 -9
- package/vendor/array-union/index.js +31 -0
- package/vendor/easy-transform-stream/index.js +58 -0
- package/vendor/globby/gitignore.js +100 -0
- package/vendor/globby/index.js +195 -0
- package/vendor/globby/node_modules/slash/index.js +16 -0
- package/vendor/globby/stream-utils.js +58 -0
- package/vendor/globby/to-path.js +20 -0
- package/vendor/gulp-imagemin/index.js +128 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/index.js +46 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
- package/vendor/ignore/index.js +468 -0
- package/vendor/imagemin/index.js +94 -0
- package/vendor/imagemin-gifsicle/index.js +37 -0
- package/vendor/imagemin-mozjpeg/index.js +104 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +264 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +128 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
- package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
- package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
- package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
- package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
- package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
- package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
- package/vendor/imagemin-optipng/index.js +44 -0
- package/vendor/imagemin-svgo/index.js +27 -0
- package/vendor/is-jpg/index.js +12 -0
- package/vendor/junk/index.js +49 -0
- package/vendor/mozjpeg/index.js +9 -0
- package/vendor/mozjpeg/lib/index.js +18 -0
- package/vendor/mozjpeg/package.json +50 -0
- package/vendor/p-pipe/index.js +26 -0
- package/vendor/plur/index.js +32 -0
- package/vendor/pretty-bytes/index.js +71 -0
- package/vendor/slash/index.js +12 -0
- package/dist/test-helpers/circularObject.js +0 -50
- package/dist/test-helpers/countMatches.js +0 -12
- package/dist/test-helpers/deepReferenceObject.js +0 -20
- package/dist/test-helpers/domItem.js +0 -33
- package/dist/test-helpers/jsonDom.js +0 -20
- package/dist/test-helpers/linkedList.js +0 -23
- package/dist/test-helpers/logObject.js +0 -21
- package/dist/test-helpers/multiReferenceObject.js +0 -20
- package/dist/test-helpers/nodeTree.js +0 -28
- package/functions/test-helpers/circularObject.js +0 -28
- package/functions/test-helpers/circularObject.test.js +0 -14
- package/functions/test-helpers/countMatches.js +0 -11
- package/functions/test-helpers/countMatches.test.js +0 -9
- package/functions/test-helpers/deepReferenceObject.js +0 -25
- package/functions/test-helpers/deepReferenceObject.test.js +0 -7
- package/functions/test-helpers/domItem.js +0 -31
- package/functions/test-helpers/domItem.test.js +0 -12
- package/functions/test-helpers/jsonDom.js +0 -16
- package/functions/test-helpers/jsonDom.test.js +0 -12
- package/functions/test-helpers/linkedList.js +0 -10
- package/functions/test-helpers/linkedList.test.js +0 -22
- package/functions/test-helpers/logObject.js +0 -18
- package/functions/test-helpers/logObject.test.js +0 -20
- package/functions/test-helpers/multiReferenceObject.js +0 -25
- package/functions/test-helpers/multiReferenceObject.test.js +0 -14
- package/functions/test-helpers/nodeTree.js +0 -11
- package/functions/test-helpers/nodeTree.test.js +0 -18
|
@@ -9,6 +9,6 @@ describe('bundleMinify', () => {
|
|
|
9
9
|
test('calls minifyFor with configurations', () => {
|
|
10
10
|
expect.assertions(1)
|
|
11
11
|
bundleMinify()
|
|
12
|
-
expect(minifyFor).toHaveBeenCalledWith(`${gulpConfig.get('
|
|
12
|
+
expect(minifyFor).toHaveBeenCalledWith(`${gulpConfig.get('browser.to')}/${gulpConfig.get('browser.name')}.js`, gulpConfig.get('browser.to'))
|
|
13
13
|
})
|
|
14
14
|
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const copyFor = require('./partials/copyFor.js')
|
|
2
|
+
const gulpConfig = require('../gulp.config.js')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Move the font files into the browser directory.
|
|
6
|
+
* @memberOf module:js-build-tools
|
|
7
|
+
* @return {stream.Stream}
|
|
8
|
+
*/
|
|
9
|
+
const copyFonts = () => copyFor(gulpConfig.get('fonts.from'), gulpConfig.get('fonts.to'))
|
|
10
|
+
|
|
11
|
+
module.exports = copyFonts
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const setUp = require('./test-helpers/setUp')
|
|
3
|
+
setUp.setDefaults('test-copy-fonts')
|
|
4
|
+
const gulpConfig = setUp.gulpConfig
|
|
5
|
+
const copyFonts = require('./copyFonts')
|
|
6
|
+
|
|
7
|
+
const fontContent = 'comic sans'
|
|
8
|
+
|
|
9
|
+
beforeEach(setUp.beforeEach)
|
|
10
|
+
|
|
11
|
+
afterEach(setUp.afterEach)
|
|
12
|
+
|
|
13
|
+
describe('copyFonts', () => {
|
|
14
|
+
test('uses the configured paths', done => {
|
|
15
|
+
const srcPath = gulpConfig.get('srcPath') + '/fonts'
|
|
16
|
+
fs.mkdirSync(srcPath, { recursive: true })
|
|
17
|
+
const fontFile = `${srcPath}/comic-sans.woff`
|
|
18
|
+
fs.writeFileSync(fontFile, fontContent)
|
|
19
|
+
const fontPath = gulpConfig.get('fonts.to')
|
|
20
|
+
expect.assertions(1)
|
|
21
|
+
copyFonts()
|
|
22
|
+
.on('finish', () => {
|
|
23
|
+
expect(fs.existsSync(fontPath)).toBeTruthy()
|
|
24
|
+
done()
|
|
25
|
+
})
|
|
26
|
+
.on('error', error => {
|
|
27
|
+
console.error('Encountered error', error)
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
}, 10000)
|
|
31
|
+
})
|
package/functions/default.js
CHANGED
|
@@ -9,6 +9,6 @@ const { series } = require('gulp')
|
|
|
9
9
|
* @param {function} [done=null]
|
|
10
10
|
* @returns {stream.Stream}
|
|
11
11
|
*/
|
|
12
|
-
const defaultCmd = (done = null) => gulpConfig.get('
|
|
12
|
+
const defaultCmd = (done = null) => gulpConfig.get('browser.enabled') ? series(dist, bundle)(done) : series(dist)(done)
|
|
13
13
|
|
|
14
14
|
module.exports = defaultCmd
|
|
@@ -10,7 +10,7 @@ jest.mock('./dist', () => jest.fn(genericFunction))
|
|
|
10
10
|
|
|
11
11
|
describe('distMinify', () => {
|
|
12
12
|
test('calls dist for nodeOnly true', done => {
|
|
13
|
-
gulpConfig.set('
|
|
13
|
+
gulpConfig.set('browser.enabled', false)
|
|
14
14
|
expect.assertions(1)
|
|
15
15
|
defaultCmd()
|
|
16
16
|
setTimeout(() => {
|
|
@@ -20,7 +20,7 @@ describe('distMinify', () => {
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
test('calls dist and bundle for nodeOnly false', done => {
|
|
23
|
-
gulpConfig.set('
|
|
23
|
+
gulpConfig.set('browser.enabled', true)
|
|
24
24
|
expect.assertions(2)
|
|
25
25
|
defaultCmd()
|
|
26
26
|
setTimeout(() => {
|
package/functions/dist.js
CHANGED
package/functions/dist.test.js
CHANGED
package/functions/distLint.js
CHANGED
|
@@ -4,16 +4,15 @@ const standard = require('gulp-standard')
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Applies Standard code style linting to distribution files.
|
|
7
|
-
* @function
|
|
8
7
|
* @memberOf module:js-build-tools
|
|
9
8
|
* @returns {*}
|
|
10
9
|
*/
|
|
11
|
-
const distLint = () => src(gulpConfig.get('
|
|
10
|
+
const distLint = () => src(gulpConfig.get('browser.from'))
|
|
12
11
|
.pipe(standard({ fix: true }))
|
|
13
12
|
.pipe(standard.reporter('default', {
|
|
14
13
|
fix: true,
|
|
15
14
|
quiet: true
|
|
16
15
|
}))
|
|
17
|
-
.pipe(dest(gulpConfig.get('
|
|
16
|
+
.pipe(dest(gulpConfig.get('dist.to')))
|
|
18
17
|
|
|
19
18
|
module.exports = distLint
|
|
@@ -3,7 +3,7 @@ const setUp = require('./test-helpers/setUp')
|
|
|
3
3
|
setUp.setDefaults('test-dist-lint')
|
|
4
4
|
const gulpConfig = setUp.gulpConfig
|
|
5
5
|
const distLint = require('./distLint')
|
|
6
|
-
const { countMatches } = require('
|
|
6
|
+
const { countMatches } = require('test-filesystem')
|
|
7
7
|
|
|
8
8
|
const lintableContents = 'const gulpConfig = require("../gulp.config.js");\n' +
|
|
9
9
|
'const { dest, src } = require("gulp");\n' +
|
|
@@ -27,7 +27,7 @@ beforeEach(
|
|
|
27
27
|
() => setUp.beforeEach()
|
|
28
28
|
.then(
|
|
29
29
|
async () => {
|
|
30
|
-
const distPath = gulpConfig.get('
|
|
30
|
+
const distPath = gulpConfig.get('dist.to')
|
|
31
31
|
await fs.mkdirSync(distPath)
|
|
32
32
|
return fs.writeFileSync(`${distPath}/distLint.js`, lintableContents)
|
|
33
33
|
}
|
|
@@ -38,7 +38,7 @@ afterEach(setUp.afterEach)
|
|
|
38
38
|
|
|
39
39
|
describe('distLint', () => {
|
|
40
40
|
test('copies the src directory and babelifies it into the dist directory', done => {
|
|
41
|
-
const distPath = gulpConfig.get('
|
|
41
|
+
const distPath = gulpConfig.get('dist.to')
|
|
42
42
|
const oldContents = fs.readFileSync(`${distPath}/distLint.js`).toString()
|
|
43
43
|
expect.assertions(4)
|
|
44
44
|
expect(countMatches(oldContents, '"')).toEqual(12)
|
package/functions/distMinify.js
CHANGED
|
@@ -3,10 +3,9 @@ const minifyFor = require('./partials/minifyFor')
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates minified versions of the dist files.
|
|
6
|
-
* @function
|
|
7
6
|
* @memberOf module:js-build-tools
|
|
8
7
|
* @returns {*}
|
|
9
8
|
*/
|
|
10
|
-
const distMinify = () => minifyFor(gulpConfig.get('
|
|
9
|
+
const distMinify = () => minifyFor(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
|
|
11
10
|
|
|
12
11
|
module.exports = distMinify
|
|
@@ -9,6 +9,6 @@ describe('distMinify', () => {
|
|
|
9
9
|
test('calls minifyFor with configurations', () => {
|
|
10
10
|
expect.assertions(1)
|
|
11
11
|
distMinify()
|
|
12
|
-
expect(minifyFor).toHaveBeenCalledWith(gulpConfig.get('
|
|
12
|
+
expect(minifyFor).toHaveBeenCalledWith(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
|
|
13
13
|
})
|
|
14
14
|
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const imagesFor = require('./partials/imagesFor.js')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Move and optimize the images into the browser folder using configured settings.
|
|
5
|
+
* @memberOf module:js-build-tools
|
|
6
|
+
* @return {stream.Stream}
|
|
7
|
+
*/
|
|
8
|
+
const images = () => imagesFor()
|
|
9
|
+
|
|
10
|
+
module.exports = images
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const setUp = require('./test-helpers/setUp')
|
|
3
|
+
setUp.setDefaults('test-images')
|
|
4
|
+
const gulpConfig = setUp.gulpConfig
|
|
5
|
+
const images = require('./images')
|
|
6
|
+
|
|
7
|
+
const imageContents = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' +
|
|
8
|
+
'<!-- Created with Inkscape (http://www.inkscape.org/) -->\n' +
|
|
9
|
+
'\n' +
|
|
10
|
+
'<svg\n' +
|
|
11
|
+
' xmlns:dc="http://purl.org/dc/elements/1.1/"\n' +
|
|
12
|
+
' xmlns:cc="http://creativecommons.org/ns#"\n' +
|
|
13
|
+
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
|
|
14
|
+
' xmlns:svg="http://www.w3.org/2000/svg"\n' +
|
|
15
|
+
' xmlns="http://www.w3.org/2000/svg"\n' +
|
|
16
|
+
' xmlns:xlink="http://www.w3.org/1999/xlink"\n' +
|
|
17
|
+
' xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n' +
|
|
18
|
+
' xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n' +
|
|
19
|
+
' id="svg2"\n' +
|
|
20
|
+
' version="1.1"\n' +
|
|
21
|
+
' inkscape:version="0.91 r13725"\n' +
|
|
22
|
+
' width="600"\n' +
|
|
23
|
+
' height="600"\n' +
|
|
24
|
+
' viewBox="0 0 600 600"\n' +
|
|
25
|
+
' sodipodi:docname="logo.svg">\n' +
|
|
26
|
+
' <metadata\n' +
|
|
27
|
+
' id="metadata8">\n' +
|
|
28
|
+
' <rdf:RDF>\n' +
|
|
29
|
+
' <cc:Work\n' +
|
|
30
|
+
' rdf:about="">\n' +
|
|
31
|
+
' <dc:format>image/svg+xml</dc:format>\n' +
|
|
32
|
+
' <dc:type\n' +
|
|
33
|
+
' rdf:resource="http://purl.org/dc/dcmitype/StillImage" />\n' +
|
|
34
|
+
' <dc:title></dc:title>\n' +
|
|
35
|
+
' </cc:Work>\n' +
|
|
36
|
+
' </rdf:RDF>\n' +
|
|
37
|
+
' </metadata>\n' +
|
|
38
|
+
' <defs\n' +
|
|
39
|
+
' id="defs6" />\n' +
|
|
40
|
+
' <sodipodi:namedview\n' +
|
|
41
|
+
' pagecolor="#ffffff"\n' +
|
|
42
|
+
' bordercolor="#666666"\n' +
|
|
43
|
+
' borderopacity="1"\n' +
|
|
44
|
+
' objecttolerance="10"\n' +
|
|
45
|
+
' gridtolerance="10"\n' +
|
|
46
|
+
' guidetolerance="10"\n' +
|
|
47
|
+
' inkscape:pageopacity="0"\n' +
|
|
48
|
+
' inkscape:pageshadow="2"\n' +
|
|
49
|
+
' inkscape:window-width="1280"\n' +
|
|
50
|
+
' inkscape:window-height="737"\n' +
|
|
51
|
+
' id="namedview4"\n' +
|
|
52
|
+
' showgrid="false"\n' +
|
|
53
|
+
' inkscape:zoom="0.39333333"\n' +
|
|
54
|
+
' inkscape:cx="300"\n' +
|
|
55
|
+
' inkscape:cy="300"\n' +
|
|
56
|
+
' inkscape:window-x="-8"\n' +
|
|
57
|
+
' inkscape:window-y="-8"\n' +
|
|
58
|
+
' inkscape:window-maximized="1"\n' +
|
|
59
|
+
' inkscape:current-layer="svg2" />\n' +
|
|
60
|
+
' <image\n' +
|
|
61
|
+
' width="600"\n' +
|
|
62
|
+
' height="600"\n' +
|
|
63
|
+
' preserveAspectRatio="none"\n' +
|
|
64
|
+
' xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n' +
|
|
65
|
+
'AAADsQAAA7EB9YPtSQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAhrSURB\n' +
|
|
66
|
+
'VHic7d3fi1x3Gcfx97M7TdKYYNPYbLaxlVZrUaK1iviToiIpeNFIwQuLBW8UEQTv9C/wSvDS+yKo\n' +
|
|
67
|
+
'CFopiFe2QVpqMKVYf0DaRmibZnfTRpNs9lez+3hxzq7T3ZnZmXO+3/PMmf284DDJzJznPGfOZ79n\n' +
|
|
68
|
+
'zpmzs+buiESZim5A9jYFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl\n' +
|
|
69
|
+
'lAIooRRACaUASigFUEIpgBKqU2dmM5spa2wAXk4bXf/vd7/3eQ6AbZumdvl/931T2+6b6rOODtzs\n' +
|
|
70
|
+
'00Ov3gY+7u5uZr2W36+33R6fBt509/XBW6A3M9sPHAPWh1ynXe/bZR0HbYN+6zwF3KgVQOBbwGzN\n' +
|
|
71
|
+
'Gq1XbJfkfgJcqTjvXcD3EvaSax2fr7sL3p+kDemlzmvblu2yXwEcX3Ve233JushLARxjB2rMO/kB\n' +
|
|
72
|
+
'NLNpah7EyEB7YQQ8UGcE1OiXV50QtSWA+xTA8VUnRHV23026xap+N0y5Cz4GHAIO97i9GziYps+R\n' +
|
|
73
|
+
'rAGXgXlgobx9G1gtp0M9ej0M3EbRc9M/WOtd/W5Oc8Bld9+oUrBr2xwHZrpuj9L8hw9LwGvANeB6\n' +
|
|
74
|
+
'17QIXKscwN2UJy1ngVPAySwL+b8V4AzwV+C/XnGlyg13D/AIcGe69nZw4AXgGWC+atBGZWYd4ATw\n' +
|
|
75
|
+
'VeAjmRf3KvAUcHHQ9sgWwK0FFEH8LnBfpkW8APzO3ZdTFTSzw8CPyLMrWwJ+7u6XMtQempl9CPgO\n' +
|
|
76
|
+
'xacuqV0Bfurua7s9MftwXKb/bKbyK8CTKcMH4O7XKX6Cc3guOnwA7v4KcC5T+X8OEz5o7v1Arhf8\n' +
|
|
77
|
+
'jLsvZar9Zoaa68CzGepW9UymukO/dk0FcIHiw//UzmeouSnHD82VcnQdC+6+ALyTofTQr10jASzf\n' +
|
|
78
|
+
'ZC9kKJ1zY85nqDk24euSo6e5YZ/Y5CF5jhHwWoaam3KMDOMYwMXUBd196NeuzRekLrt7jlDnNI4B\n' +
|
|
79
|
+
'DO2pzQHMOfrlMo4BTD4CjqLNAVyNbqCCoU5NNCy0pzYHUCaAAiihFEAJpQBKKAVQQimAEkoBlFAK\n' +
|
|
80
|
+
'oIRSACWUAiihFEAJpQBKKAVQQimAEkoBlFAKoIRSACWUAiihFEAJpS+YbNZDZvZgdBPbHIlcuALY\n' +
|
|
81
|
+
'rCMEb/Bxo12whFIAJZQCKKEUQAmlAEooBVBCKYASSgGUUDoR3awLwMXoJrb5IHn/JMVACmCzXnL3\n' +
|
|
82
|
+
'P0c30c3MThMYQO2CJVSbA5jlT3hLs9ocwDb3LqU2b0SNgBOgzQFsc+9SavNG1Ag4AdocwDb3LqU2\n' +
|
|
83
|
+
'b8Q29y6lNm9E7YIngAIoodocQJkACqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIo\n' +
|
|
84
|
+
'oRRACdXmAN7MXF9X21RkZkPnqs0BXM1c/z2Z60+yoV87BbC/Q5nrT7KhXzsFsL/DGWqO4249R08K\n' +
|
|
85
|
+
'YAI5RsCjGWrWlaOnPRHAlcz135ehZtiXAA0wm6HmHcM+sc0BzDYCmtlB4BMZSufY2JWZ2a3AbRlK\n' +
|
|
86
|
+
'f8bMpod5ogLY2xeAWzLUPWBm4zQK3pOp7nuBTw3zxDYHMPku2MyOmdm3gYdT1+7yTTO7PWP9oZjZ\n' +
|
|
87
|
+
'CeDRjIv4hpk9ZmYD/zJUm7+gsvIIWJ4ovR2YAY6X0+a/c/9QzgI/NrPXgZeBt4BF4Ho5Lbr7RooF\n' +
|
|
88
|
+
'mVmH4oDgcNftDHBf2UfOo3IDPgk8YGaXgDlgvpzmgP+4u++pAJqZAT+k2AiR6z4FfKCctnMzWwZ+\n' +
|
|
89
|
+
'7+7nqhQ3s68AXwZurd5iMtPA+8up25qZXWjzLnjkALq7A8cY75HfgIMUG66qacYjfIPsA+5ocwCr\n' +
|
|
90
|
+
'vgfMff4wlbWgeZu02uYAXqk4X2s2To1527KOa00GMOUuYdndr1WctzUbJ2jeJq00GcCUV5fM1Zi3\n' +
|
|
91
|
+
'NRunxrxteZvRzC64PO2RcgS8VGPetgRwL+yCV5s6GjxI2nNOdUbA54DzgHdNG31uh33cKdZvc5rq\n' +
|
|
92
|
+
'c9vvvl7/v15jHeeBP/RZhzrraQy/nsM8/npTAUx9cecrVWd097+lbGQcuftV4E/RfQyjqfeAKQP4\n' +
|
|
93
|
+
'lrsvJKwngZoKYMprzv6RsJYEGxhAM7vXzD6dYDkfT1Bj098T1pJgO94DlkesJ4EvAXeX930U+LW7\n' +
|
|
94
|
+
'j3xqoLzm7MP12txy0d3/naiWjIF3BbAM32PsvBjzY8CdZvaEu4/6925PUu9zzW5/TFRHxsTWLri8\n' +
|
|
95
|
+
'gvVx+l8JfBT4gZl9fsRlpLqy+DV3/1eiWjImut8DnqYY6QbpAI+a2eNmtn+34uWu+/4a/XXT6DeB\n' +
|
|
96
|
+
'OgDlZeKfG2G+B4ATZvZbdz/f6wlmdj/F7jyFl/otR9rN3B0z+z5wb8Ual4CzwBvAMsWVxg9S7HpT\n' +
|
|
97
|
+
'fPrxNvCzKgdAMv46Znac6uGD4tLu04n62e4m8ITCN7mmgLuimxjgyQpH3dIiHXZeqz8OHHjK3Z+P\n' +
|
|
98
|
+
'bkTy6pDuHF0qDvzG3c9GNyL5TQEXopvosg78QuHbOzrAq9FNlK4Cv3L3l6MbkeZ03P2qmV1mhC+U\n' +
|
|
99
|
+
'yeAcxQHHcmAPEmDzk5AzQcu/QXGa5ZcK395kxe9qg5mdAk41tNw14FngaXdfamiZMoa2AghgZl8H\n' +
|
|
100
|
+
'vphxee9Q/E7G0+6+mHE50hLbA2jA14CHSHt6Zg54EfiLu9f5ZRuZMO8K4NadxdeHPUzx7UZVP8+9\n' +
|
|
101
|
+
'TBG6F919vnKHMtF6BnDrQbNZ4LMU3yY1w84v7naKX6C+QXFRwhubk7vfyNGwTJaBAdzxZLMDwBGK\n' +
|
|
102
|
+
'g4glYMVHKSCyzUgBFEmtzd+OJRNAAZRQCqCEUgAllAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAl\n' +
|
|
103
|
+
'lAIooRRACaUASigFUEIpgBJKAZRQCqCEUgAllAIooRRACaUASigFUEL9D1MqMi7YkUEVAAAAAElF\n' +
|
|
104
|
+
'TkSuQmCC\n' +
|
|
105
|
+
'"\n' +
|
|
106
|
+
' id="image10"\n' +
|
|
107
|
+
' x="0"\n' +
|
|
108
|
+
' y="0" />\n' +
|
|
109
|
+
' <path\n' +
|
|
110
|
+
' style="fill:#000000"\n' +
|
|
111
|
+
' d="M 19.039097,494.38241 C 2.0018627,482.75861 -2.8301068,468.02182 5.0071177,451.587 8.2776829,444.72855 15.162733,436.35919 20.307229,432.98839 c 8.904129,-5.83422 9.948263,-5.67522 21.727331,3.30915 28.014638,21.3678 44.091105,18.882 51.54879,-7.97059 C 99.533959,406.9008 98.83533,123.18555 92.8125,115.28305 90.196335,111.85041 81.496733,108.63382 73.125,108.00381 58.734191,106.92084 58.077731,106.30388 56.961131,92.8125 L 55.797259,78.75 l 163.053411,0 163.05342,0 2.57381,11.71845 c 2.93006,13.34047 -1.71086,18.13302 -17.64754,18.22413 C 347.54041,108.80285 345,115.82292 345,169.01786 l 0,48.48214 67.5,0 67.5,0 0,-48.1688 c 0,-41.90267 -0.89209,-48.97614 -6.85778,-54.37499 C 469.37044,111.54279 462.75847,108.75 458.44894,108.75 443.44309,108.75 438.75,104.6341 438.75,91.473791 l 0,-12.723791 80.85139,0 80.85135,0 -1.16385,14.0625 c -1.13201,13.67745 -1.60515,14.09431 -17.27948,15.22432 -13.44982,0.96964 -16.73767,2.79799 -19.87627,11.0531 -5.80185,15.26002 -2.83763,249.42009 3.25016,256.74719 2.61705,3.14985 11.47643,6.80123 19.6875,8.11425 14.52533,2.32268 14.9292,2.79386 14.9292,17.41755 l 0,15.03026 -79.6875,-1.01208 -79.6875,-1.01209 -1.1367,-13.60684 c -1.13565,-13.59401 -1.11975,-13.60939 16.875,-16.30515 9.90645,-1.4841 19.25149,-4.64227 20.76679,-7.01816 1.5153,-2.37593 2.78092,-30.05423 2.8125,-61.50735 L 480,258.75 l -67.59289,0 -67.5929,0 1.0304,60.9375 1.03039,60.9375 19.6875,3.3399 c 20.4921,3.4764 22.16576,5.78036 17.32391,23.8476 -2.25337,8.40847 -2.53065,8.4375 -80.57378,8.4375 l -78.31263,0 0,-14.95567 c 0,-14.53673 0.41823,-15.02258 14.9292,-17.34297 8.21107,-1.31302 17.07044,-4.96657 19.6875,-8.11909 3.63727,-4.38139 4.7583,-35.56081 4.7583,-132.34294 0,-69.63615 -1.23091,-127.84279 -2.73535,-129.3481 -9.73748,-9.7431 -68.9232,-8.34789 -79.15408,1.86593 -3.08612,3.08097 -4.99292,46.77065 -6.52417,149.48557 -1.45514,97.60931 -3.64592,149.67975 -6.6905,159.01994 -13.55129,41.57292 -61.40288,74.9124 -111.000242,77.33685 -22.754302,1.11229 -28.166407,0.0821 -39.231561,-7.46711 z"\n' +
|
|
112
|
+
' id="path3338"\n' +
|
|
113
|
+
' inkscape:connector-curvature="0" />\n' +
|
|
114
|
+
'</svg>\n'
|
|
115
|
+
|
|
116
|
+
beforeEach(setUp.beforeEach)
|
|
117
|
+
|
|
118
|
+
afterEach(setUp.afterEach)
|
|
119
|
+
|
|
120
|
+
describe('images', () => {
|
|
121
|
+
test('uses the configured paths', done => {
|
|
122
|
+
const srcPath = gulpConfig.get('srcPath') + '/img'
|
|
123
|
+
fs.mkdirSync(srcPath, { recursive: true })
|
|
124
|
+
const imageFile = `${srcPath}/imageToCopy.svg`
|
|
125
|
+
fs.writeFileSync(imageFile, imageContents)
|
|
126
|
+
const imagePath = gulpConfig.get('images.to')
|
|
127
|
+
expect.assertions(1)
|
|
128
|
+
images()
|
|
129
|
+
.on('finish', () => {
|
|
130
|
+
expect(fs.existsSync(imagePath)).toBeTruthy()
|
|
131
|
+
done()
|
|
132
|
+
})
|
|
133
|
+
.on('error', error => {
|
|
134
|
+
console.error('Encountered error', error)
|
|
135
|
+
done()
|
|
136
|
+
})
|
|
137
|
+
}, 10000)
|
|
138
|
+
})
|
|
@@ -6,14 +6,13 @@ const { globSync } = require('glob')
|
|
|
6
6
|
/**
|
|
7
7
|
* Appends all the jsdoc comments to the readme file. Assumes empty or templated file.
|
|
8
8
|
* Configure this with 'readmeSearch', 'readmePath', 'readmeFile', and 'readmeOptions'.
|
|
9
|
-
* @function
|
|
10
9
|
* @memberOf module:partials
|
|
11
10
|
* @returns {string|Uint8Array}
|
|
12
11
|
*/
|
|
13
12
|
const addToReadme = () => jsdoc2md
|
|
14
|
-
.render({ files: globSync(gulpConfig.get('
|
|
13
|
+
.render({ files: globSync(gulpConfig.get('readme.from')) })
|
|
15
14
|
.then(
|
|
16
|
-
readme => fs.appendFileSync(gulpConfig.get('
|
|
15
|
+
readme => fs.appendFileSync(gulpConfig.get('readme.to') + gulpConfig.get('readme.file'), readme, gulpConfig.get('readmeOptions'))
|
|
17
16
|
)
|
|
18
17
|
|
|
19
18
|
module.exports = addToReadme
|
|
@@ -2,7 +2,7 @@ const fs = require('fs')
|
|
|
2
2
|
const setUp = require('../test-helpers/setUp')
|
|
3
3
|
setUp.setDefaults('test-add-to-readme')
|
|
4
4
|
const gulpConfig = setUp.gulpConfig
|
|
5
|
-
gulpConfig.set('
|
|
5
|
+
gulpConfig.set('dist.from', 'test-temp/src/addToReadme.js')
|
|
6
6
|
const addToReadme = require('./addToReadme')
|
|
7
7
|
|
|
8
8
|
const rawContents = '/**\n' +
|
|
@@ -21,7 +21,7 @@ afterEach(setUp.afterEach)
|
|
|
21
21
|
|
|
22
22
|
describe('addToReadme', () => {
|
|
23
23
|
test('generates the documentation', async () => {
|
|
24
|
-
const readmeFilePath = gulpConfig.get('
|
|
24
|
+
const readmeFilePath = gulpConfig.get('readme.to') + gulpConfig.get('readme.file')
|
|
25
25
|
expect.assertions(2)
|
|
26
26
|
await addToReadme()
|
|
27
27
|
await expect(fs.existsSync(readmeFilePath)).toBeTruthy()
|
|
@@ -3,10 +3,9 @@ const { watch } = require('gulp')
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a chokidar instance which watches and triggers change when the globed files are modified.
|
|
6
|
-
* @function
|
|
7
6
|
* @memberOf module:partials
|
|
8
7
|
* @returns {FSWatcher}
|
|
9
8
|
*/
|
|
10
|
-
const beginWatcher = () => watch(gulpConfig.get('
|
|
9
|
+
const beginWatcher = () => watch(gulpConfig.get('test.watch'))
|
|
11
10
|
|
|
12
11
|
module.exports = beginWatcher
|
|
@@ -10,7 +10,7 @@ afterEach(setUp.afterEach)
|
|
|
10
10
|
|
|
11
11
|
describe('beginWatcher', () => {
|
|
12
12
|
test('returns instance of EventEmitter / FSWatcher', () => {
|
|
13
|
-
gulpConfig.set('
|
|
13
|
+
gulpConfig.set('test.watch', 'test-begin-watcher/*.js')
|
|
14
14
|
const fsWatcher = beginWatcher()
|
|
15
15
|
expect(fsWatcher).toBeInstanceOf(EventEmitter)
|
|
16
16
|
fsWatcher.close()
|
|
@@ -4,7 +4,6 @@ const removeDirectory = require('./removeDirectory')
|
|
|
4
4
|
/**
|
|
5
5
|
* Deletes all the distribution and browser files (used before create a new build).
|
|
6
6
|
* Configure array of directories to remove with 'cleanPaths'.
|
|
7
|
-
* @function
|
|
8
7
|
* @memberOf module:partials
|
|
9
8
|
* @returns {Promise<string[]> | *}
|
|
10
9
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { dest, src } = require('gulp')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copy some files to a different location.
|
|
5
|
+
* @memberOf module:partials
|
|
6
|
+
* @param {string|array} srcPath
|
|
7
|
+
* @param {string} destPath
|
|
8
|
+
* @returns {stream.Stream}
|
|
9
|
+
*/
|
|
10
|
+
const copyFor = (srcPath, destPath) => src(srcPath)
|
|
11
|
+
.pipe(dest(destPath))
|
|
12
|
+
|
|
13
|
+
module.exports = copyFor
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const setUp = require('../test-helpers/setUp')
|
|
3
|
+
setUp.setDefaults('test-copy-for')
|
|
4
|
+
const gulpConfig = setUp.gulpConfig
|
|
5
|
+
const copyFor = require('./copyFor')
|
|
6
|
+
|
|
7
|
+
const fileContents = 'some file contents'
|
|
8
|
+
|
|
9
|
+
beforeEach(setUp.beforeEach)
|
|
10
|
+
|
|
11
|
+
afterEach(setUp.afterEach)
|
|
12
|
+
|
|
13
|
+
describe('copyFor', () => {
|
|
14
|
+
test('copies the file and ', done => {
|
|
15
|
+
const srcPath = gulpConfig.get('srcPath')
|
|
16
|
+
const copyFile = `${srcPath}/fileToCopy.txt`
|
|
17
|
+
fs.writeFileSync(copyFile, fileContents)
|
|
18
|
+
expect.assertions(3)
|
|
19
|
+
const oldContents = fs.readFileSync(copyFile).toString()
|
|
20
|
+
expect(oldContents).toEqual(fileContents)
|
|
21
|
+
const browserPath = gulpConfig.get('browser.to')
|
|
22
|
+
copyFor(copyFile, browserPath)
|
|
23
|
+
.on('finish', () => {
|
|
24
|
+
expect(fs.existsSync(browserPath)).toBeTruthy()
|
|
25
|
+
const movedContents = fs.readFileSync(`${browserPath}/fileToCopy.txt`).toString()
|
|
26
|
+
expect(movedContents).toEqual(fileContents)
|
|
27
|
+
done()
|
|
28
|
+
})
|
|
29
|
+
.on('error', error => {
|
|
30
|
+
console.error('Encountered error', error)
|
|
31
|
+
done()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -5,13 +5,12 @@ const gulpConfig = require('../../gulp.config.js')
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Build the distribution for a given source pattern.
|
|
8
|
-
* @function
|
|
9
8
|
* @memberOf module:partials
|
|
10
9
|
* @param {string|array} [srcPath='src/config/path/dist/for']
|
|
11
10
|
* @param {string} [destPath='dist/config/path']
|
|
12
11
|
* @returns {stream.Stream}
|
|
13
12
|
*/
|
|
14
|
-
const distFor = (srcPath = distForSrc(), destPath = gulpConfig.get('
|
|
13
|
+
const distFor = (srcPath = distForSrc(), destPath = gulpConfig.get('dist.to')) => src(srcPath)
|
|
15
14
|
.pipe(babel())
|
|
16
15
|
.pipe(dest(destPath))
|
|
17
16
|
|
|
@@ -3,7 +3,7 @@ const setUp = require('../test-helpers/setUp')
|
|
|
3
3
|
setUp.setDefaults('test-dist-for')
|
|
4
4
|
const gulpConfig = setUp.gulpConfig
|
|
5
5
|
const distFor = require('./distFor')
|
|
6
|
-
const { countMatches } = require('
|
|
6
|
+
const { countMatches } = require('test-filesystem')
|
|
7
7
|
const typeScript = require('../typeScript')
|
|
8
8
|
|
|
9
9
|
const rawContents = 'const babel = require(\'gulp-babel\')\n' +
|
|
@@ -71,7 +71,7 @@ describe('distFor', () => {
|
|
|
71
71
|
expect.assertions(5)
|
|
72
72
|
const oldContents = fs.readFileSync(srcFile).toString()
|
|
73
73
|
expect(countMatches(oldContents, 'const ')).toEqual(7)
|
|
74
|
-
const distPath = gulpConfig.get('
|
|
74
|
+
const distPath = gulpConfig.get('dist.to')
|
|
75
75
|
distFor(srcFile)
|
|
76
76
|
.on('finish', () => {
|
|
77
77
|
expect(fs.existsSync(distPath)).toBeTruthy()
|
|
@@ -99,7 +99,7 @@ describe('distFor', () => {
|
|
|
99
99
|
expect.assertions(7)
|
|
100
100
|
const oldContents = fs.readFileSync(srcFile).toString()
|
|
101
101
|
expect(countMatches(oldContents, 'const ')).toEqual(3)
|
|
102
|
-
const distPath = gulpConfig.get('
|
|
102
|
+
const distPath = gulpConfig.get('dist.to')
|
|
103
103
|
typeScript(() => {
|
|
104
104
|
distFor()
|
|
105
105
|
.on('finish', () => {
|
|
@@ -109,7 +109,7 @@ describe('distFor', () => {
|
|
|
109
109
|
expect(countMatches(babelifiedContents, 'const ')).toEqual(0)
|
|
110
110
|
expect(countMatches(babelifiedContents, 'var ')).toEqual(8)
|
|
111
111
|
expect(countMatches(babelifiedContents, 'function')).toEqual(1)
|
|
112
|
-
expect(countMatches(babelifiedContents, 'Object.defineProperty(exports, "__esModule", {
|
|
112
|
+
expect(countMatches(babelifiedContents, 'Object.defineProperty(exports, "__esModule", {')).toEqual(1)
|
|
113
113
|
done()
|
|
114
114
|
})
|
|
115
115
|
.on('error', error => {
|
|
@@ -2,13 +2,12 @@ const gulpConfig = require('../../gulp.config')
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve the correct distFor search path based on TS Config.
|
|
5
|
-
* @function
|
|
6
5
|
* @memberOf module:partials
|
|
7
6
|
* @param {module:gulpConfig~FlagStringSetting} [useTs='config/for/ts']
|
|
8
7
|
* @returns {string}
|
|
9
8
|
*/
|
|
10
|
-
const distForSrc = (useTs = gulpConfig.get('
|
|
11
|
-
? gulpConfig.get('
|
|
12
|
-
: gulpConfig.get('
|
|
9
|
+
const distForSrc = (useTs = gulpConfig.get('typescript.enabled')) => useTs
|
|
10
|
+
? gulpConfig.get('browser.from')
|
|
11
|
+
: gulpConfig.get('dist.from')
|
|
13
12
|
|
|
14
13
|
module.exports = distForSrc
|
|
@@ -3,15 +3,15 @@ const gulpConfig = setUp.gulpConfig
|
|
|
3
3
|
const distForSrc = require('./distForSrc')
|
|
4
4
|
|
|
5
5
|
describe('distForSrc', () => {
|
|
6
|
-
test('
|
|
6
|
+
test('typescript.enabled as false returns srcSearch', () => {
|
|
7
7
|
expect.assertions(1)
|
|
8
|
-
gulpConfig.set('
|
|
9
|
-
expect(distForSrc()).toBe(gulpConfig.get('
|
|
8
|
+
gulpConfig.set('typescript.enabled', false)
|
|
9
|
+
expect(distForSrc()).toBe(gulpConfig.get('dist.from'))
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
test('
|
|
12
|
+
test('typescript.enabled as true returns distSearch', () => {
|
|
13
13
|
expect.assertions(1)
|
|
14
|
-
gulpConfig.set('
|
|
15
|
-
expect(distForSrc()).toBe(gulpConfig.get('
|
|
14
|
+
gulpConfig.set('typescript.enabled', true)
|
|
15
|
+
expect(distForSrc()).toBe(gulpConfig.get('browser.from'))
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -6,17 +6,16 @@ const tsFor = require('./tsFor')
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* When using TypeScript, ensure that we process the ts first then run babel (dist)
|
|
9
|
-
* @function
|
|
10
9
|
* @memberOf module:partials
|
|
11
10
|
* @param {string} [srcPath='src/config/path/dist/for']
|
|
12
11
|
* @param {string} [distFinalPath='dist/config/path']
|
|
13
12
|
* @param {string} [tsSearch='ts/search/config/path']
|
|
14
13
|
* @returns {function(null=): stream.Stream}
|
|
15
14
|
*/
|
|
16
|
-
const distSeries = (srcPath = distForSrc(), distFinalPath = gulpConfig.get('
|
|
15
|
+
const distSeries = (srcPath = distForSrc(), distFinalPath = gulpConfig.get('dist.to'), tsSearch = gulpConfig.get('typescript.from')) => {
|
|
17
16
|
const typescript = tsFor(tsSearch, distFinalPath)
|
|
18
17
|
const dist = () => distFor(srcPath, distFinalPath)
|
|
19
|
-
return gulpConfig.get('
|
|
18
|
+
return gulpConfig.get('typescript.enabled')
|
|
20
19
|
? series(typescript, dist)
|
|
21
20
|
: dist
|
|
22
21
|
}
|
|
@@ -11,22 +11,22 @@ jest.mock('./tsFor', () => jest.fn(() => genericFunction))
|
|
|
11
11
|
|
|
12
12
|
describe('distSeries', () => {
|
|
13
13
|
test('when not using ts config only returns runnable distFor', done => {
|
|
14
|
-
gulpConfig.set('
|
|
14
|
+
gulpConfig.set('typescript.enabled', false)
|
|
15
15
|
expect.assertions(1)
|
|
16
16
|
distSeries()()
|
|
17
17
|
setTimeout(() => {
|
|
18
|
-
expect(distFor).toHaveBeenCalledWith(gulpConfig.get('
|
|
18
|
+
expect(distFor).toHaveBeenCalledWith(gulpConfig.get('dist.from'), gulpConfig.get('dist.to'))
|
|
19
19
|
done()
|
|
20
20
|
}, 500)
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
test('when using ts config returns runnable series of tsFor and distFor', done => {
|
|
24
|
-
gulpConfig.set('
|
|
24
|
+
gulpConfig.set('typescript.enabled', true)
|
|
25
25
|
expect.assertions(2)
|
|
26
26
|
distSeries()()
|
|
27
27
|
setTimeout(() => {
|
|
28
|
-
expect(tsFor).toHaveBeenCalledWith(gulpConfig.get('
|
|
29
|
-
expect(distFor).toHaveBeenCalledWith(gulpConfig.get('
|
|
28
|
+
expect(tsFor).toHaveBeenCalledWith(gulpConfig.get('typescript.from'), gulpConfig.get('dist.to'))
|
|
29
|
+
expect(distFor).toHaveBeenCalledWith(gulpConfig.get('browser.from'), gulpConfig.get('dist.to'))
|
|
30
30
|
done()
|
|
31
31
|
}, 500)
|
|
32
32
|
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const cache = require('gulp-cache')
|
|
2
|
+
const { dest, src } = require('gulp')
|
|
3
|
+
const gulpConfig = require('../../gulp.config.js')
|
|
4
|
+
|
|
5
|
+
let imagemin = (content) => content
|
|
6
|
+
try {
|
|
7
|
+
imagemin = require('../../vendor/gulp-imagemin').default
|
|
8
|
+
} catch (e) {
|
|
9
|
+
// It didn't get created yet
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Move and optimize images into the browser directory.
|
|
14
|
+
* @memberOf module:partials
|
|
15
|
+
* @param {string|array} [imageSrc=src/images/pattern]
|
|
16
|
+
* @param {string} [imageDest=dest/image/folder]
|
|
17
|
+
* @return {stream.Stream}
|
|
18
|
+
*/
|
|
19
|
+
const imagesFor = (imageSrc = gulpConfig.get('images.from'), imageDest = gulpConfig.get('images.to')) =>
|
|
20
|
+
src(imageSrc)
|
|
21
|
+
.pipe(
|
|
22
|
+
// Caching images that ran through imagemin
|
|
23
|
+
cache(
|
|
24
|
+
imagemin({
|
|
25
|
+
interlaced: true,
|
|
26
|
+
silent: true,
|
|
27
|
+
verbose: false,
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.pipe(dest(imageDest))
|
|
32
|
+
|
|
33
|
+
module.exports = imagesFor
|