mod-build 3.7.6 → 3.7.8
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/CHANGELOG.md +4 -0
- package/gulp-tasks/grab-cdn.js +22 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/gulp-tasks/grab-cdn.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
/* globals Promise */
|
|
1
2
|
var request = require('request');
|
|
2
3
|
var source = require('vinyl-source-stream');
|
|
3
4
|
|
|
4
5
|
// helper to allow us to define an "end" event to multiple streams
|
|
5
|
-
function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName) {
|
|
6
|
+
async function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName, index) {
|
|
6
7
|
var url = `https://${siteSettings.nodeEnv}${inputPath}`;
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
return await new Promise(async function(resolve) { // eslint-disable-line no-undef
|
|
9
|
+
console.time(`${index + 1} Finished after`);
|
|
10
|
+
console.log(`${index + 1} Starting:`, url);
|
|
9
11
|
request(url)
|
|
10
|
-
.on('response', resp
|
|
12
|
+
.on('response', async function(resp) {
|
|
11
13
|
if (resp.statusCode !== 200) {
|
|
12
14
|
throw new Error(`Error fetching ${url}`);
|
|
13
15
|
}
|
|
16
|
+
console.timeEnd(`${index + 1} Finished after`);
|
|
14
17
|
})
|
|
15
18
|
.pipe(source(fileName))
|
|
16
19
|
.pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
|
|
@@ -19,7 +22,7 @@ function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName)
|
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
22
|
-
return function() {
|
|
25
|
+
return async function() {
|
|
23
26
|
const { nodeEnv, isLocal } = siteSettings;
|
|
24
27
|
const { isQSPage, isWhiteLabel, domain } = siteData;
|
|
25
28
|
const isModWhiteLabel = isWhiteLabel && !isQSPage;
|
|
@@ -43,7 +46,7 @@ module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
if (isModWhiteLabel || domainHasModernize) {
|
|
46
|
-
Object.assign(externalResources, {'/quote/resources/mod-site/templates/scripts/recaptcha.html': ['/templates/scripts/', 'recaptcha.html']});
|
|
49
|
+
Object.assign(externalResources, { '/quote/resources/mod-site/templates/scripts/recaptcha.html': ['/templates/scripts/', 'recaptcha.html'] });
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
// local dev files
|
|
@@ -67,13 +70,19 @@ module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
|
67
70
|
]
|
|
68
71
|
});
|
|
69
72
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const totalRequests = Object.keys(externalResources).length;
|
|
74
|
+
return await new Promise(async function(resolve) {
|
|
75
|
+
const sequentialRequests = async function(key, index) {
|
|
76
|
+
if (index === totalRequests) {
|
|
77
|
+
resolve();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const destinationPath = externalResources[key][0];
|
|
81
|
+
const fileName = externalResources[key][1];
|
|
82
|
+
return await streamToDestination(gulp, siteSettings, key, destinationPath, fileName, index).then(() => sequentialRequests(Object.keys(externalResources)[index + 1], index + 1));
|
|
83
|
+
};
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
sequentialRequests(Object.keys(externalResources)[0], 0);
|
|
86
|
+
});
|
|
78
87
|
};
|
|
79
88
|
};
|