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,260 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.execa = execa;
7
- exports.execaCommand = execaCommand;
8
- exports.execaCommandSync = execaCommandSync;
9
- exports.execaNode = execaNode;
10
- exports.execaSync = execaSync;
11
- require("core-js/modules/esnext.async-iterator.filter.js");
12
- require("core-js/modules/esnext.iterator.constructor.js");
13
- require("core-js/modules/esnext.iterator.filter.js");
14
- require("core-js/modules/web.dom-collections.iterator.js");
15
- var _nodeBuffer = require("node:buffer");
16
- var _nodePath = _interopRequireDefault(require("node:path"));
17
- var _nodeChild_process = _interopRequireDefault(require("node:child_process"));
18
- var _nodeProcess = _interopRequireDefault(require("node:process"));
19
- var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
20
- var _index = _interopRequireDefault(require("../strip-final-newline/index.js"));
21
- var _index2 = require("../npm-run-path/index.js");
22
- var _index3 = _interopRequireDefault(require("../onetime/index.js"));
23
- var _error = require("./lib/error.js");
24
- var _stdio = require("./lib/stdio.js");
25
- var _kill = require("./lib/kill.js");
26
- var _stream = require("./lib/stream.js");
27
- var _promise = require("./lib/promise.js");
28
- var _command = require("./lib/command.js");
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
- const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
31
- const getEnv = _ref => {
32
- let {
33
- env: envOption,
34
- extendEnv,
35
- preferLocal,
36
- localDir,
37
- execPath
38
- } = _ref;
39
- const env = extendEnv ? {
40
- ..._nodeProcess.default.env,
41
- ...envOption
42
- } : envOption;
43
- if (preferLocal) {
44
- return (0, _index2.npmRunPathEnv)({
45
- env,
46
- cwd: localDir,
47
- execPath
48
- });
49
- }
50
- return env;
51
- };
52
- const handleArguments = function (file, args) {
53
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54
- const parsed = _crossSpawn.default._parse(file, args, options);
55
- file = parsed.command;
56
- args = parsed.args;
57
- options = parsed.options;
58
- options = {
59
- maxBuffer: DEFAULT_MAX_BUFFER,
60
- buffer: true,
61
- stripFinalNewline: true,
62
- extendEnv: true,
63
- preferLocal: false,
64
- localDir: options.cwd || _nodeProcess.default.cwd(),
65
- execPath: _nodeProcess.default.execPath,
66
- encoding: 'utf8',
67
- reject: true,
68
- cleanup: true,
69
- all: false,
70
- windowsHide: true,
71
- ...options
72
- };
73
- options.env = getEnv(options);
74
- options.stdio = (0, _stdio.normalizeStdio)(options);
75
- if (_nodeProcess.default.platform === 'win32' && _nodePath.default.basename(file, '.exe') === 'cmd') {
76
- // #116
77
- args.unshift('/q');
78
- }
79
- return {
80
- file,
81
- args,
82
- options,
83
- parsed
84
- };
85
- };
86
- const handleOutput = (options, value, error) => {
87
- if (typeof value !== 'string' && !_nodeBuffer.Buffer.isBuffer(value)) {
88
- // When `execaSync()` errors, we normalize it to '' to mimic `execa()`
89
- return error === undefined ? undefined : '';
90
- }
91
- if (options.stripFinalNewline) {
92
- return (0, _index.default)(value);
93
- }
94
- return value;
95
- };
96
- function execa(file, args, options) {
97
- const parsed = handleArguments(file, args, options);
98
- const command = (0, _command.joinCommand)(file, args);
99
- const escapedCommand = (0, _command.getEscapedCommand)(file, args);
100
- (0, _kill.validateTimeout)(parsed.options);
101
- let spawned;
102
- try {
103
- spawned = _nodeChild_process.default.spawn(parsed.file, parsed.args, parsed.options);
104
- } catch (error) {
105
- // Ensure the returned error is always both a promise and a child process
106
- const dummySpawned = new _nodeChild_process.default.ChildProcess();
107
- const errorPromise = Promise.reject((0, _error.makeError)({
108
- error,
109
- stdout: '',
110
- stderr: '',
111
- all: '',
112
- command,
113
- escapedCommand,
114
- parsed,
115
- timedOut: false,
116
- isCanceled: false,
117
- killed: false
118
- }));
119
- return (0, _promise.mergePromise)(dummySpawned, errorPromise);
120
- }
121
- const spawnedPromise = (0, _promise.getSpawnedPromise)(spawned);
122
- const timedPromise = (0, _kill.setupTimeout)(spawned, parsed.options, spawnedPromise);
123
- const processDone = (0, _kill.setExitHandler)(spawned, parsed.options, timedPromise);
124
- const context = {
125
- isCanceled: false
126
- };
127
- spawned.kill = _kill.spawnedKill.bind(null, spawned.kill.bind(spawned));
128
- spawned.cancel = _kill.spawnedCancel.bind(null, spawned, context);
129
- const handlePromise = async () => {
130
- const [{
131
- error,
132
- exitCode,
133
- signal,
134
- timedOut
135
- }, stdoutResult, stderrResult, allResult] = await (0, _stream.getSpawnedResult)(spawned, parsed.options, processDone);
136
- const stdout = handleOutput(parsed.options, stdoutResult);
137
- const stderr = handleOutput(parsed.options, stderrResult);
138
- const all = handleOutput(parsed.options, allResult);
139
- if (error || exitCode !== 0 || signal !== null) {
140
- const returnedError = (0, _error.makeError)({
141
- error,
142
- exitCode,
143
- signal,
144
- stdout,
145
- stderr,
146
- all,
147
- command,
148
- escapedCommand,
149
- parsed,
150
- timedOut,
151
- isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
152
- killed: spawned.killed
153
- });
154
- if (!parsed.options.reject) {
155
- return returnedError;
156
- }
157
- throw returnedError;
158
- }
159
- return {
160
- command,
161
- escapedCommand,
162
- exitCode: 0,
163
- stdout,
164
- stderr,
165
- all,
166
- failed: false,
167
- timedOut: false,
168
- isCanceled: false,
169
- killed: false
170
- };
171
- };
172
- const handlePromiseOnce = (0, _index3.default)(handlePromise);
173
- (0, _stream.handleInput)(spawned, parsed.options.input);
174
- spawned.all = (0, _stream.makeAllStream)(spawned, parsed.options);
175
- return (0, _promise.mergePromise)(spawned, handlePromiseOnce);
176
- }
177
- function execaSync(file, args, options) {
178
- const parsed = handleArguments(file, args, options);
179
- const command = (0, _command.joinCommand)(file, args);
180
- const escapedCommand = (0, _command.getEscapedCommand)(file, args);
181
- (0, _stream.validateInputSync)(parsed.options);
182
- let result;
183
- try {
184
- result = _nodeChild_process.default.spawnSync(parsed.file, parsed.args, parsed.options);
185
- } catch (error) {
186
- throw (0, _error.makeError)({
187
- error,
188
- stdout: '',
189
- stderr: '',
190
- all: '',
191
- command,
192
- escapedCommand,
193
- parsed,
194
- timedOut: false,
195
- isCanceled: false,
196
- killed: false
197
- });
198
- }
199
- const stdout = handleOutput(parsed.options, result.stdout, result.error);
200
- const stderr = handleOutput(parsed.options, result.stderr, result.error);
201
- if (result.error || result.status !== 0 || result.signal !== null) {
202
- const error = (0, _error.makeError)({
203
- stdout,
204
- stderr,
205
- error: result.error,
206
- signal: result.signal,
207
- exitCode: result.status,
208
- command,
209
- escapedCommand,
210
- parsed,
211
- timedOut: result.error && result.error.code === 'ETIMEDOUT',
212
- isCanceled: false,
213
- killed: result.signal !== null
214
- });
215
- if (!parsed.options.reject) {
216
- return error;
217
- }
218
- throw error;
219
- }
220
- return {
221
- command,
222
- escapedCommand,
223
- exitCode: 0,
224
- stdout,
225
- stderr,
226
- failed: false,
227
- timedOut: false,
228
- isCanceled: false,
229
- killed: false
230
- };
231
- }
232
- function execaCommand(command, options) {
233
- const [file, ...args] = (0, _command.parseCommand)(command);
234
- return execa(file, args, options);
235
- }
236
- function execaCommandSync(command, options) {
237
- const [file, ...args] = (0, _command.parseCommand)(command);
238
- return execaSync(file, args, options);
239
- }
240
- function execaNode(scriptPath, args) {
241
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
242
- if (args && !Array.isArray(args) && typeof args === 'object') {
243
- options = args;
244
- args = [];
245
- }
246
- const stdio = (0, _stdio.normalizeStdioNode)(options);
247
- const defaultExecArgv = _nodeProcess.default.execArgv.filter(arg => !arg.startsWith('--inspect'));
248
- const {
249
- nodePath = _nodeProcess.default.execPath,
250
- nodeOptions = defaultExecArgv
251
- } = options;
252
- return execa(nodePath, [...nodeOptions, scriptPath, ...(Array.isArray(args) ? args : [])], {
253
- ...options,
254
- stdin: undefined,
255
- stdout: undefined,
256
- stderr: undefined,
257
- stdio,
258
- shell: false
259
- });
260
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseCommand = exports.joinCommand = exports.getEscapedCommand = void 0;
7
- require("core-js/modules/es.string.replace.js");
8
- require("core-js/modules/esnext.async-iterator.map.js");
9
- require("core-js/modules/esnext.iterator.map.js");
10
- require("core-js/modules/web.dom-collections.iterator.js");
11
- const normalizeArgs = function (file) {
12
- let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
13
- if (!Array.isArray(args)) {
14
- return [file];
15
- }
16
- return [file, ...args];
17
- };
18
- const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
19
- const DOUBLE_QUOTES_REGEXP = /"/g;
20
- const escapeArg = arg => {
21
- if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
22
- return arg;
23
- }
24
- return "\"".concat(arg.replace(DOUBLE_QUOTES_REGEXP, '\\"'), "\"");
25
- };
26
- const joinCommand = (file, args) => normalizeArgs(file, args).join(' ');
27
- exports.joinCommand = joinCommand;
28
- const getEscapedCommand = (file, args) => normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
29
- exports.getEscapedCommand = getEscapedCommand;
30
- const SPACES_REGEXP = / +/g;
31
-
32
- // Handle `execaCommand()`
33
- const parseCommand = command => {
34
- const tokens = [];
35
- for (const token of command.trim().split(SPACES_REGEXP)) {
36
- // Allow spaces to be escaped by a backslash if not meant as a delimiter
37
- const previousToken = tokens[tokens.length - 1];
38
- if (previousToken && previousToken.endsWith('\\')) {
39
- // Merge previous token with current one
40
- tokens[tokens.length - 1] = "".concat(previousToken.slice(0, -1), " ").concat(token);
41
- } else {
42
- tokens.push(token);
43
- }
44
- }
45
- return tokens;
46
- };
47
- exports.parseCommand = parseCommand;
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.makeError = void 0;
7
- require("core-js/modules/esnext.async-iterator.filter.js");
8
- require("core-js/modules/esnext.iterator.constructor.js");
9
- require("core-js/modules/esnext.iterator.filter.js");
10
- var _main = require("../../human-signals/build/src/main.js");
11
- const getErrorPrefix = _ref => {
12
- let {
13
- timedOut,
14
- timeout,
15
- errorCode,
16
- signal,
17
- signalDescription,
18
- exitCode,
19
- isCanceled
20
- } = _ref;
21
- if (timedOut) {
22
- return "timed out after ".concat(timeout, " milliseconds");
23
- }
24
- if (isCanceled) {
25
- return 'was canceled';
26
- }
27
- if (errorCode !== undefined) {
28
- return "failed with ".concat(errorCode);
29
- }
30
- if (signal !== undefined) {
31
- return "was killed with ".concat(signal, " (").concat(signalDescription, ")");
32
- }
33
- if (exitCode !== undefined) {
34
- return "failed with exit code ".concat(exitCode);
35
- }
36
- return 'failed';
37
- };
38
- const makeError = _ref2 => {
39
- let {
40
- stdout,
41
- stderr,
42
- all,
43
- error,
44
- signal,
45
- exitCode,
46
- command,
47
- escapedCommand,
48
- timedOut,
49
- isCanceled,
50
- killed,
51
- parsed: {
52
- options: {
53
- timeout
54
- }
55
- }
56
- } = _ref2;
57
- // `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
58
- // We normalize them to `undefined`
59
- exitCode = exitCode === null ? undefined : exitCode;
60
- signal = signal === null ? undefined : signal;
61
- const signalDescription = signal === undefined ? undefined : _main.signalsByName[signal].description;
62
- const errorCode = error && error.code;
63
- const prefix = getErrorPrefix({
64
- timedOut,
65
- timeout,
66
- errorCode,
67
- signal,
68
- signalDescription,
69
- exitCode,
70
- isCanceled
71
- });
72
- const execaMessage = "Command ".concat(prefix, ": ").concat(command);
73
- const isError = Object.prototype.toString.call(error) === '[object Error]';
74
- const shortMessage = isError ? "".concat(execaMessage, "\n").concat(error.message) : execaMessage;
75
- const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
76
- if (isError) {
77
- error.originalMessage = error.message;
78
- error.message = message;
79
- } else {
80
- error = new Error(message);
81
- }
82
- error.shortMessage = shortMessage;
83
- error.command = command;
84
- error.escapedCommand = escapedCommand;
85
- error.exitCode = exitCode;
86
- error.signal = signal;
87
- error.signalDescription = signalDescription;
88
- error.stdout = stdout;
89
- error.stderr = stderr;
90
- if (all !== undefined) {
91
- error.all = all;
92
- }
93
- if ('bufferedData' in error) {
94
- delete error.bufferedData;
95
- }
96
- error.failed = true;
97
- error.timedOut = Boolean(timedOut);
98
- error.isCanceled = isCanceled;
99
- error.killed = killed && !timedOut;
100
- return error;
101
- };
102
- exports.makeError = makeError;
@@ -1,123 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validateTimeout = exports.spawnedKill = exports.spawnedCancel = exports.setupTimeout = exports.setExitHandler = void 0;
7
- require("core-js/modules/es.promise.finally.js");
8
- require("core-js/modules/web.dom-collections.iterator.js");
9
- var _nodeOs = _interopRequireDefault(require("node:os"));
10
- var _signalExit = require("signal-exit");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
13
-
14
- // Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
15
- const spawnedKill = function (kill) {
16
- let signal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'SIGTERM';
17
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18
- const killResult = kill(signal);
19
- setKillTimeout(kill, signal, options, killResult);
20
- return killResult;
21
- };
22
- exports.spawnedKill = spawnedKill;
23
- const setKillTimeout = (kill, signal, options, killResult) => {
24
- if (!shouldForceKill(signal, options, killResult)) {
25
- return;
26
- }
27
- const timeout = getForceKillAfterTimeout(options);
28
- const t = setTimeout(() => {
29
- kill('SIGKILL');
30
- }, timeout);
31
-
32
- // Guarded because there's no `.unref()` when `execa` is used in the renderer
33
- // process in Electron. This cannot be tested since we don't run tests in
34
- // Electron.
35
- // istanbul ignore else
36
- if (t.unref) {
37
- t.unref();
38
- }
39
- };
40
- const shouldForceKill = (signal, _ref, killResult) => {
41
- let {
42
- forceKillAfterTimeout
43
- } = _ref;
44
- return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
45
- };
46
- const isSigterm = signal => signal === _nodeOs.default.constants.signals.SIGTERM || typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM';
47
- const getForceKillAfterTimeout = _ref2 => {
48
- let {
49
- forceKillAfterTimeout = true
50
- } = _ref2;
51
- if (forceKillAfterTimeout === true) {
52
- return DEFAULT_FORCE_KILL_TIMEOUT;
53
- }
54
- if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
55
- throw new TypeError("Expected the `forceKillAfterTimeout` option to be a non-negative integer, got `".concat(forceKillAfterTimeout, "` (").concat(typeof forceKillAfterTimeout, ")"));
56
- }
57
- return forceKillAfterTimeout;
58
- };
59
-
60
- // `childProcess.cancel()`
61
- const spawnedCancel = (spawned, context) => {
62
- const killResult = spawned.kill();
63
- if (killResult) {
64
- context.isCanceled = true;
65
- }
66
- };
67
- exports.spawnedCancel = spawnedCancel;
68
- const timeoutKill = (spawned, signal, reject) => {
69
- spawned.kill(signal);
70
- reject(Object.assign(new Error('Timed out'), {
71
- timedOut: true,
72
- signal
73
- }));
74
- };
75
-
76
- // `timeout` option handling
77
- const setupTimeout = (spawned, _ref3, spawnedPromise) => {
78
- let {
79
- timeout,
80
- killSignal = 'SIGTERM'
81
- } = _ref3;
82
- if (timeout === 0 || timeout === undefined) {
83
- return spawnedPromise;
84
- }
85
- let timeoutId;
86
- const timeoutPromise = new Promise((resolve, reject) => {
87
- timeoutId = setTimeout(() => {
88
- timeoutKill(spawned, killSignal, reject);
89
- }, timeout);
90
- });
91
- const safeSpawnedPromise = spawnedPromise.finally(() => {
92
- clearTimeout(timeoutId);
93
- });
94
- return Promise.race([timeoutPromise, safeSpawnedPromise]);
95
- };
96
- exports.setupTimeout = setupTimeout;
97
- const validateTimeout = _ref4 => {
98
- let {
99
- timeout
100
- } = _ref4;
101
- if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
102
- throw new TypeError("Expected the `timeout` option to be a non-negative integer, got `".concat(timeout, "` (").concat(typeof timeout, ")"));
103
- }
104
- };
105
-
106
- // `cleanup` option handling
107
- exports.validateTimeout = validateTimeout;
108
- const setExitHandler = async (spawned, _ref5, timedPromise) => {
109
- let {
110
- cleanup,
111
- detached
112
- } = _ref5;
113
- if (!cleanup || detached) {
114
- return timedPromise;
115
- }
116
- const removeExitHandler = (0, _signalExit.onExit)(() => {
117
- spawned.kill();
118
- });
119
- return timedPromise.finally(() => {
120
- removeExitHandler();
121
- });
122
- };
123
- exports.setExitHandler = setExitHandler;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergePromise = exports.getSpawnedPromise = void 0;
7
- require("core-js/modules/web.dom-collections.iterator.js");
8
- const nativePromisePrototype = (async () => {})().constructor.prototype;
9
- const descriptors = ['then', 'catch', 'finally'].map(property => [property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)]);
10
-
11
- // The return value is a mixin of `childProcess` and `Promise`
12
- const mergePromise = (spawned, promise) => {
13
- for (const [property, descriptor] of descriptors) {
14
- // Starting the main `promise` is deferred to avoid consuming streams
15
- const value = typeof promise === 'function' ? function () {
16
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17
- args[_key] = arguments[_key];
18
- }
19
- return Reflect.apply(descriptor.value, promise(), args);
20
- } : descriptor.value.bind(promise);
21
- Reflect.defineProperty(spawned, property, {
22
- ...descriptor,
23
- value
24
- });
25
- }
26
- return spawned;
27
- };
28
-
29
- // Use promises instead of `child_process` events
30
- exports.mergePromise = mergePromise;
31
- const getSpawnedPromise = spawned => new Promise((resolve, reject) => {
32
- spawned.on('exit', (exitCode, signal) => {
33
- resolve({
34
- exitCode,
35
- signal
36
- });
37
- });
38
- spawned.on('error', error => {
39
- reject(error);
40
- });
41
- if (spawned.stdin) {
42
- spawned.stdin.on('error', error => {
43
- reject(error);
44
- });
45
- }
46
- });
47
- exports.getSpawnedPromise = getSpawnedPromise;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.normalizeStdioNode = exports.normalizeStdio = void 0;
7
- require("core-js/modules/web.dom-collections.iterator.js");
8
- const aliases = ['stdin', 'stdout', 'stderr'];
9
- const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
10
- const normalizeStdio = options => {
11
- if (!options) {
12
- return;
13
- }
14
- const {
15
- stdio
16
- } = options;
17
- if (stdio === undefined) {
18
- return aliases.map(alias => options[alias]);
19
- }
20
- if (hasAlias(options)) {
21
- throw new Error("It's not possible to provide `stdio` in combination with one of ".concat(aliases.map(alias => "`".concat(alias, "`")).join(', ')));
22
- }
23
- if (typeof stdio === 'string') {
24
- return stdio;
25
- }
26
- if (!Array.isArray(stdio)) {
27
- throw new TypeError("Expected `stdio` to be of type `string` or `Array`, got `".concat(typeof stdio, "`"));
28
- }
29
- const length = Math.max(stdio.length, aliases.length);
30
- return Array.from({
31
- length
32
- }, (value, index) => stdio[index]);
33
- };
34
-
35
- // `ipc` is pushed unless it is already present
36
- exports.normalizeStdio = normalizeStdio;
37
- const normalizeStdioNode = options => {
38
- const stdio = normalizeStdio(options);
39
- if (stdio === 'ipc') {
40
- return 'ipc';
41
- }
42
- if (stdio === undefined || typeof stdio === 'string') {
43
- return [stdio, stdio, stdio, 'ipc'];
44
- }
45
- if (stdio.includes('ipc')) {
46
- return stdio;
47
- }
48
- return [...stdio, 'ipc'];
49
- };
50
- exports.normalizeStdioNode = normalizeStdioNode;