js-build-tools 1.2.2 → 2.1.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 (140) hide show
  1. package/README.md +590 -267
  2. package/dist/build.js +30 -23
  3. package/dist/build.min.js +1 -1
  4. package/dist/bundle.js +18 -15
  5. package/dist/bundle.min.js +1 -1
  6. package/dist/bundleLint.js +24 -20
  7. package/dist/bundleLint.min.js +1 -1
  8. package/dist/bundleMinify.js +16 -20
  9. package/dist/bundleMinify.min.js +1 -1
  10. package/dist/compileReadme.js +15 -13
  11. package/dist/compileReadme.min.js +1 -1
  12. package/dist/default.js +19 -14
  13. package/dist/default.min.js +1 -1
  14. package/dist/dist.js +14 -10
  15. package/dist/dist.min.js +1 -1
  16. package/dist/distLint.js +23 -20
  17. package/dist/distLint.min.js +1 -1
  18. package/dist/distMinify.js +15 -20
  19. package/dist/distMinify.min.js +1 -1
  20. package/dist/partials/addToReadme.js +25 -0
  21. package/dist/partials/beginWatcher.js +16 -0
  22. package/dist/partials/clean.js +21 -0
  23. package/dist/partials/distFor.js +23 -0
  24. package/dist/partials/distForSrc.js +16 -0
  25. package/dist/partials/distSeries.js +31 -0
  26. package/dist/partials/minifyFor.js +21 -0
  27. package/dist/partials/readmeTemplate.js +18 -0
  28. package/dist/partials/runOnChange.js +63 -0
  29. package/dist/partials/tsFor.js +24 -0
  30. package/dist/partials.js +33 -0
  31. package/dist/partials.min.js +1 -0
  32. package/dist/test-helpers/circularObject.js +50 -0
  33. package/dist/test-helpers/countMatches.js +16 -0
  34. package/dist/test-helpers/deepReferenceObject.js +20 -0
  35. package/dist/test-helpers/domItem.js +33 -0
  36. package/dist/test-helpers/jsonDom.js +20 -0
  37. package/dist/test-helpers/linkedList.js +23 -0
  38. package/dist/test-helpers/logObject.js +24 -0
  39. package/dist/test-helpers/multiReferenceObject.js +20 -0
  40. package/dist/test-helpers/nodeTree.js +28 -0
  41. package/dist/test-helpers/setUp.js +127 -0
  42. package/dist/testFull.js +24 -13
  43. package/dist/testFull.min.js +1 -1
  44. package/dist/testHelpers.js +33 -198
  45. package/dist/testHelpers.min.js +1 -1
  46. package/dist/testQuick.js +26 -15
  47. package/dist/testQuick.min.js +1 -1
  48. package/dist/typeScript.js +14 -0
  49. package/dist/typeScript.min.js +1 -0
  50. package/dist/watchFull.js +14 -21
  51. package/dist/watchFull.min.js +1 -1
  52. package/dist/watchTest.js +16 -14
  53. package/dist/watchTest.min.js +1 -1
  54. package/functions/build.js +28 -25
  55. package/functions/build.test.js +59 -0
  56. package/functions/bundle.js +17 -15
  57. package/functions/bundle.test.js +68 -0
  58. package/functions/bundleLint.js +19 -17
  59. package/functions/bundleLint.test.js +61 -0
  60. package/functions/bundleMinify.js +12 -15
  61. package/functions/bundleMinify.test.js +14 -0
  62. package/functions/compileReadme.js +11 -10
  63. package/functions/compileReadme.test.js +18 -0
  64. package/functions/default.js +14 -11
  65. package/functions/default.test.js +32 -0
  66. package/functions/dist.js +11 -9
  67. package/functions/dist.test.js +43 -0
  68. package/functions/distLint.js +19 -17
  69. package/functions/distLint.test.js +58 -0
  70. package/functions/distMinify.js +12 -15
  71. package/functions/distMinify.test.js +14 -0
  72. package/functions/partials/addToReadme.js +20 -0
  73. package/functions/partials/addToReadme.test.js +28 -0
  74. package/functions/partials/beginWatcher.js +12 -0
  75. package/functions/partials/beginWatcher.test.js +18 -0
  76. package/functions/partials/clean.js +14 -0
  77. package/functions/partials/clean.test.js +20 -0
  78. package/functions/partials/distFor.js +18 -0
  79. package/functions/partials/distFor.test.js +125 -0
  80. package/functions/partials/distForSrc.js +14 -0
  81. package/functions/partials/distForSrc.test.js +17 -0
  82. package/functions/partials/distSeries.js +21 -0
  83. package/functions/partials/distSeries.test.js +33 -0
  84. package/functions/partials/minifyFor.js +16 -0
  85. package/functions/partials/minifyFor.test.js +48 -0
  86. package/functions/partials/readmeTemplate.js +15 -0
  87. package/functions/partials/readmeTemplate.test.js +33 -0
  88. package/functions/partials/runOnChange.js +57 -0
  89. package/functions/partials/runOnChange.test.js +93 -0
  90. package/functions/partials/tsFor.js +21 -0
  91. package/functions/partials/tsFor.test.js +44 -0
  92. package/functions/partials.js +32 -0
  93. package/functions/partials.test.js +7 -0
  94. package/functions/test-helpers/circularObject.js +28 -0
  95. package/functions/test-helpers/circularObject.test.js +14 -0
  96. package/functions/test-helpers/countMatches.js +11 -0
  97. package/functions/test-helpers/countMatches.test.js +9 -0
  98. package/functions/test-helpers/deepReferenceObject.js +25 -0
  99. package/functions/test-helpers/deepReferenceObject.test.js +7 -0
  100. package/functions/test-helpers/domItem.js +31 -0
  101. package/functions/test-helpers/domItem.test.js +12 -0
  102. package/functions/test-helpers/jsonDom.js +16 -0
  103. package/functions/test-helpers/jsonDom.test.js +12 -0
  104. package/functions/test-helpers/linkedList.js +10 -0
  105. package/functions/test-helpers/linkedList.test.js +22 -0
  106. package/functions/test-helpers/logObject.js +18 -0
  107. package/functions/test-helpers/logObject.test.js +20 -0
  108. package/functions/test-helpers/multiReferenceObject.js +25 -0
  109. package/functions/test-helpers/multiReferenceObject.test.js +14 -0
  110. package/functions/test-helpers/nodeTree.js +11 -0
  111. package/functions/test-helpers/nodeTree.test.js +18 -0
  112. package/functions/test-helpers/setUp.js +67 -0
  113. package/functions/test-helpers/setUp.test.js +18 -0
  114. package/functions/testFull.js +20 -10
  115. package/functions/testFull.test.js +16 -0
  116. package/functions/testHelpers.js +27 -137
  117. package/functions/testHelpers.test.js +7 -100
  118. package/functions/testQuick.js +20 -10
  119. package/functions/testQuick.test.js +16 -0
  120. package/functions/typeScript.js +11 -0
  121. package/functions/typeScript.test.js +10 -0
  122. package/functions/watchFull.js +6 -12
  123. package/functions/watchFull.test.js +40 -0
  124. package/functions/watchTest.js +4 -2
  125. package/functions/watchTest.test.js +48 -0
  126. package/gulp.config.js +161 -16
  127. package/gulpfile.base.js +9 -0
  128. package/package.json +11 -11
  129. package/dist/addToReadme.js +0 -22
  130. package/dist/addToReadme.min.js +0 -1
  131. package/dist/clean.js +0 -11
  132. package/dist/clean.min.js +0 -1
  133. package/dist/distFor.js +0 -21
  134. package/dist/distFor.min.js +0 -1
  135. package/dist/readmeTemplate.js +0 -15
  136. package/dist/readmeTemplate.min.js +0 -1
  137. package/functions/addToReadme.js +0 -17
  138. package/functions/clean.js +0 -10
  139. package/functions/distFor.js +0 -15
  140. package/functions/readmeTemplate.js +0 -13
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _require = require('gulp'),
4
+ dest = _require.dest,
5
+ src = _require.src;
6
+ var gulpConfig = require('../../gulp.config.js');
7
+ var ts = require('gulp-typescript');
8
+ var tsProject = ts.createProject(gulpConfig.get('useTsConfig'));
9
+
10
+ /**
11
+ * Starting at the source directory, find all the ts files and convert them into the distribution directory.
12
+ * @function
13
+ * @memberOf module:partials
14
+ * @param {string|array} [srcPath='']
15
+ * @param {string} [distPath='']
16
+ * @returns {stream.Stream}
17
+ * @see `https://www.typescriptlang.org/docs/handbook/gulp.html` for more info
18
+ */
19
+ var tsFor = function tsFor() {
20
+ var srcPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gulpConfig.get('tsSearch');
21
+ var distPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('distPath');
22
+ return src(srcPath).pipe(tsProject()).js.pipe(dest(distPath));
23
+ };
24
+ module.exports = tsFor;
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ /**
4
+ * Micro-functions used as components for the main gulp functions.
5
+ * @file
6
+ * @author Joshua Heagle <joshuaheagle@gmail.com>
7
+ * @version 2.0.0
8
+ * @module partials
9
+ * @memberOf module:js-build-tools
10
+ */
11
+
12
+ var addToReadme = require('./partials/addToReadme')
13
+ var beginWatcher = require('./partials/beginWatcher')
14
+ var clean = require('./partials/clean')
15
+ var distFor = require('./partials/distFor')
16
+ var distForSrc = require('./partials/distForSrc')
17
+ var distSeries = require('./partials/distSeries')
18
+ var minifyFor = require('./partials/minifyFor')
19
+ var readmeTemplate = require('./partials/readmeTemplate')
20
+ var runOnChange = require('./partials/runOnChange')
21
+ var tsFor = require('./partials/tsFor')
22
+ module.exports = {
23
+ addToReadme: addToReadme,
24
+ beginWatcher: beginWatcher,
25
+ clean: clean,
26
+ distFor: distFor,
27
+ distForSrc: distForSrc,
28
+ distSeries: distSeries,
29
+ minifyFor: minifyFor,
30
+ readmeTemplate: readmeTemplate,
31
+ runOnChange: runOnChange,
32
+ tsFor: tsFor
33
+ }
@@ -0,0 +1 @@
1
+ "use strict";var addToReadme=require("./partials/addToReadme"),beginWatcher=require("./partials/beginWatcher"),clean=require("./partials/clean"),distFor=require("./partials/distFor"),distForSrc=require("./partials/distForSrc"),distSeries=require("./partials/distSeries"),minifyFor=require("./partials/minifyFor"),readmeTemplate=require("./partials/readmeTemplate"),runOnChange=require("./partials/runOnChange"),tsFor=require("./partials/tsFor");module.exports={addToReadme:addToReadme,beginWatcher:beginWatcher,clean:clean,distFor:distFor,distForSrc:distForSrc,distSeries:distSeries,minifyFor:minifyFor,readmeTemplate:readmeTemplate,runOnChange:runOnChange,tsFor:tsFor};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Multilayered node tree-like structure with parent references
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object|Array>}
7
+ */
8
+ var circularObject = {
9
+ name: 'root',
10
+ parent: {},
11
+ body: {},
12
+ head: {},
13
+ children: []
14
+ };
15
+ circularObject.children = [{
16
+ name: 'body',
17
+ parent: {},
18
+ children: []
19
+ }, {
20
+ name: 'head',
21
+ parent: {},
22
+ children: []
23
+ }];
24
+ circularObject.body = circularObject.children[0];
25
+ circularObject.head = circularObject.children[1];
26
+ circularObject.body.parent = circularObject;
27
+ circularObject.head.parent = circularObject;
28
+ circularObject.body.children = [{
29
+ name: 'body child one',
30
+ parent: {},
31
+ children: []
32
+ }, {
33
+ name: 'body child two',
34
+ parent: {},
35
+ children: []
36
+ }];
37
+ circularObject.body.children[0].parent = circularObject.body;
38
+ circularObject.body.children[1].parent = circularObject.body;
39
+ circularObject.head.children = [{
40
+ name: 'head child one',
41
+ parent: {},
42
+ children: []
43
+ }, {
44
+ name: 'head child two',
45
+ parent: {},
46
+ children: []
47
+ }];
48
+ circularObject.head.children[0].parent = circularObject.head;
49
+ circularObject.head.children[1].parent = circularObject.head;
50
+ module.exports = circularObject;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.regexp.exec.js");
4
+ require("core-js/modules/es.string.split.js");
5
+ /**
6
+ * Simple way to count string occurrences for testing.
7
+ * @function
8
+ * @memberOf module:testHelpers
9
+ * @param {string} content
10
+ * @param {string} search
11
+ * @returns {number}
12
+ */
13
+ var countMatches = function countMatches(content, search) {
14
+ return content.split(search).length - 1;
15
+ };
16
+ module.exports = countMatches;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample object with deep references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Object>}
7
+ */
8
+ var deepReferenceObject = {
9
+ object1: {
10
+ name: 'someName',
11
+ object2: {
12
+ age: 12,
13
+ array1: ['someString', 'anotherString']
14
+ },
15
+ array2: [89, 32]
16
+ },
17
+ title: 'Some Title',
18
+ item: 45
19
+ };
20
+ module.exports = deepReferenceObject;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of domItem child with nested child and optional details
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Array|Object>}
7
+ */
8
+ var domItem = [{
9
+ attributes: {
10
+ className: 'row',
11
+ style: {}
12
+ },
13
+ axis: 'y',
14
+ children: [{
15
+ attributes: {
16
+ style: {}
17
+ },
18
+ axis: 'x',
19
+ children: [],
20
+ element: {},
21
+ eventListeners: {},
22
+ hasShip: false,
23
+ isHit: false,
24
+ parentItem: {},
25
+ point: {},
26
+ tagName: 'div'
27
+ }],
28
+ element: null,
29
+ eventListeners: {},
30
+ parentItem: {},
31
+ tagName: 'div'
32
+ }];
33
+ module.exports = domItem;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of jsonDom object containing empty nested array and objects
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Array|Object>}
7
+ */
8
+ var jsonDom = {
9
+ tagName: 'div',
10
+ attributes: {
11
+ style: {},
12
+ className: 'column'
13
+ },
14
+ element: null,
15
+ eventListeners: {},
16
+ parentItem: {},
17
+ children: [],
18
+ axis: 'x'
19
+ };
20
+ module.exports = jsonDom;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample LinkedList for testing circular references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object>}
7
+ */
8
+ var linkedList = {
9
+ name: 'one',
10
+ prev: null,
11
+ next: null
12
+ };
13
+ linkedList.next = {
14
+ name: 'two',
15
+ prev: linkedList,
16
+ next: null
17
+ };
18
+ linkedList.next.next = {
19
+ name: 'three',
20
+ prev: linkedList.next,
21
+ next: null
22
+ };
23
+ module.exports = linkedList;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.json.stringify.js");
4
+ /**
5
+ * Log out an object in a nicely formatted way.
6
+ * @function
7
+ * @memberOf module:testHelpers
8
+ * @param {Object} object
9
+ * @param {string} [label=logging]
10
+ * @param {string} [outputType=log]
11
+ * @returns {string|undefined}
12
+ */
13
+ var logObject = function logObject(object) {
14
+ var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'logging';
15
+ var outputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'log';
16
+ var logger = outputType === 'string' ? function (label, object) {
17
+ return "'".concat(label, "' | ") + JSON.stringify(object);
18
+ } : console[outputType];
19
+ if (typeof require === 'undefined' || outputType === 'string') {
20
+ return logger(label, object);
21
+ }
22
+ return logger(label, require('util').inspect(object, false, null, true));
23
+ };
24
+ module.exports = logObject;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample of object containing multiple references.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|number|Object>}
7
+ */
8
+ var multiReferenceObject = {
9
+ object1: {
10
+ name: 'someName'
11
+ },
12
+ object2: {
13
+ age: 12
14
+ },
15
+ array1: ['someString', 'anotherString'],
16
+ array2: [89, 32],
17
+ title: 'Some Title',
18
+ item: 45
19
+ };
20
+ module.exports = multiReferenceObject;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sample NodeTree for testing circular references and arrays.
5
+ * @memberOf module:testHelpers
6
+ * @type {Object.<string, string|Object|Array>}
7
+ */
8
+ var nodeTree = {
9
+ name: 'one',
10
+ parent: null,
11
+ children: []
12
+ };
13
+ nodeTree.children[0] = {
14
+ name: 'child one',
15
+ parent: nodeTree,
16
+ children: []
17
+ };
18
+ nodeTree.children[1] = {
19
+ name: 'child two',
20
+ parent: nodeTree,
21
+ children: []
22
+ };
23
+ nodeTree.children[0].children[0] = {
24
+ name: 'grandchild one',
25
+ parent: nodeTree.children[0],
26
+ children: []
27
+ };
28
+ module.exports = nodeTree;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ require("core-js/modules/es.object.define-property.js");
5
+ require("core-js/modules/es.symbol.js");
6
+ require("core-js/modules/es.symbol.description.js");
7
+ require("core-js/modules/es.symbol.iterator.js");
8
+ require("core-js/modules/es.array.iterator.js");
9
+ require("core-js/modules/es.string.iterator.js");
10
+ require("core-js/modules/web.dom-collections.iterator.js");
11
+ require("core-js/modules/es.symbol.async-iterator.js");
12
+ require("core-js/modules/es.symbol.to-string-tag.js");
13
+ require("core-js/modules/es.json.to-string-tag.js");
14
+ require("core-js/modules/es.math.to-string-tag.js");
15
+ require("core-js/modules/es.object.get-prototype-of.js");
16
+ require("core-js/modules/esnext.async-iterator.for-each.js");
17
+ require("core-js/modules/esnext.iterator.constructor.js");
18
+ require("core-js/modules/esnext.iterator.for-each.js");
19
+ require("core-js/modules/web.dom-collections.for-each.js");
20
+ require("core-js/modules/es.object.set-prototype-of.js");
21
+ require("core-js/modules/es.array.slice.js");
22
+ require("core-js/modules/es.object.to-string.js");
23
+ require("core-js/modules/es.promise.js");
24
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
25
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
26
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
27
+ var fs = require('fs');
28
+ var del = require('del');
29
+ // Import the configurations and override some of them in order to direct to the temp directory.
30
+ var gulpConfig = require('../../gulp.config.js');
31
+ var tempDir = 'test-temp/';
32
+ var srcPath = "".concat(tempDir, "src");
33
+
34
+ /**
35
+ * Update the gulp configurations with the test data. Set the test directory where temp files will be created for testing.
36
+ * @function
37
+ * @memberOf module:testHelpers
38
+ * @param {string} testDir
39
+ */
40
+ var setDefaults = function setDefaults() {
41
+ var testDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'test-temp';
42
+ tempDir = "".concat(testDir, "/");
43
+ srcPath = "".concat(tempDir, "src");
44
+ gulpConfig.set('browserPath', "".concat(tempDir, "browser"));
45
+ gulpConfig.set('distMain', "".concat(tempDir, "dist/main"));
46
+ gulpConfig.set('distPath', "".concat(tempDir, "dist"));
47
+ gulpConfig.set('distSearch', "".concat(tempDir, "dist/**/*.js"));
48
+ gulpConfig.set('readmeTemplate', "".concat(tempDir, "MAIN.md"));
49
+ gulpConfig.set('readmePath', tempDir);
50
+ gulpConfig.set('rootPath', tempDir);
51
+ gulpConfig.set('srcPath', srcPath);
52
+ gulpConfig.set('srcSearch', "".concat(tempDir, "src/**/!(*.test).js"));
53
+ gulpConfig.set('tsSearch', "".concat(tempDir, "src/**/*.ts"));
54
+ gulpConfig.set('watchSearch', "".concat(tempDir, "src/**/*.js"));
55
+ };
56
+ exports.setDefaults = setDefaults;
57
+ exports.gulpConfig = gulpConfig;
58
+
59
+ /**
60
+ * Ensure that the del has completed, recursively attempt to delete and recreate
61
+ * @function
62
+ * @memberOf module:testHelpers
63
+ * @param {boolean} [exists=true]
64
+ * @returns {Promise<*|void>}
65
+ */
66
+ var createTempDir = /*#__PURE__*/function () {
67
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
68
+ var exists,
69
+ _args = arguments;
70
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ exists = _args.length > 0 && _args[0] !== undefined ? _args[0] : true;
74
+ if (!exists) {
75
+ _context.next = 3;
76
+ break;
77
+ }
78
+ return _context.abrupt("return", del(tempDir).then(function () {
79
+ return createTempDir(fs.existsSync(tempDir));
80
+ }));
81
+ case 3:
82
+ _context.next = 5;
83
+ return fs.mkdirSync(tempDir);
84
+ case 5:
85
+ return _context.abrupt("return", fs.mkdirSync(srcPath));
86
+ case 6:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee);
91
+ }));
92
+ return function createTempDir() {
93
+ return _ref.apply(this, arguments);
94
+ };
95
+ }();
96
+ exports.createTempDir = createTempDir;
97
+
98
+ /**
99
+ * In the Jest.beforeEach function call this one to set up the temp directory.
100
+ * @function
101
+ * @memberOf module:testHelpers
102
+ * @returns {Promise<*|void>}
103
+ */
104
+ exports.beforeEach = function () {
105
+ return createTempDir();
106
+ };
107
+
108
+ /**
109
+ * In the Jest.afterEach function call this one to clean up and remove the temp directory.
110
+ * @function
111
+ * @memberOf module:testHelpers
112
+ * @returns {Promise<*>}
113
+ */
114
+ exports.afterEach = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
115
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
+ while (1) switch (_context2.prev = _context2.next) {
117
+ case 0:
118
+ _context2.next = 2;
119
+ return del(tempDir);
120
+ case 2:
121
+ return _context2.abrupt("return", _context2.sent);
122
+ case 3:
123
+ case "end":
124
+ return _context2.stop();
125
+ }
126
+ }, _callee2);
127
+ }));
package/dist/testFull.js CHANGED
@@ -1,13 +1,24 @@
1
- 'use strict'
2
-
3
- const gulpConfig = require('../gulp.config.js')
4
- const {
5
- runCLI: jest
6
- } = require('jest')
7
-
8
- /**
9
- * Run all tests with jest.
10
- * @returns {Promise<*>}
11
- */
12
- const testFull = async () => await jest({}, gulpConfig.testPath)
13
- module.exports = testFull
1
+ 'use strict'
2
+
3
+ var gulpConfig = require('../gulp.config.js')
4
+ var _require = require('jest')
5
+ var runCLI = _require.runCLI
6
+
7
+ /**
8
+ * Run all tests with jest.
9
+ * @function
10
+ * @memberOf module:js-build-tools
11
+ * @param {function} [done=null]
12
+ * @param {Array.<string>|string} [testPath='path/config/test/files']
13
+ * @returns {Promise<*>}
14
+ */
15
+ var testFull = function testFull () {
16
+ var done = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
17
+ var testPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gulpConfig.get('testPath')
18
+ if (!Array.isArray(testPath)) {
19
+ // The testPath must be an array of strings
20
+ testPath = [testPath]
21
+ }
22
+ return runCLI(gulpConfig.get('testOptions'), testPath)
23
+ }
24
+ module.exports = testFull
@@ -1 +1 @@
1
- "use strict";const gulpConfig=require("../gulp.config.js"),{runCLI:jest}=require("jest"),testFull=async()=>await jest({},gulpConfig.testPath);module.exports=testFull;
1
+ "use strict";var gulpConfig=require("../gulp.config.js"),_require=require("jest"),runCLI=_require.runCLI,testFull=function(){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gulpConfig.get("testPath");return Array.isArray(r)||(r=[r]),runCLI(gulpConfig.get("testOptions"),r)};module.exports=testFull;