mod-build 3.7.7-beta.1 → 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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## 3.7.7
3
+ ## 3.7.8
4
4
 
5
- - Adding `isMobile` handlebars helper to determine if screen is < 768px
5
+ - removed race condition from grab-cdn task.
6
6
 
7
7
  ## 3.7.6
8
8
 
@@ -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
- return new Promise(resolve => { // eslint-disable-line no-undef
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 filesPromiseMap = Object.keys(externalResources).map(key => {
71
- const destinationPath = externalResources[key][0];
72
- const fileName = externalResources[key][1];
73
- return streamToDestination(gulp, siteSettings, key, destinationPath, fileName);
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
- // when Promise.all resolves, the streams are done and we can go to the next step
77
- return Promise.all(filesPromiseMap); // eslint-disable-line no-undef
85
+ sequentialRequests(Object.keys(externalResources)[0], 0);
86
+ });
78
87
  };
79
88
  };
@@ -194,17 +194,6 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
194
194
  return index;
195
195
  }
196
196
  },
197
- // Adding helper to check if mobile (< 768px)
198
- {
199
- name: 'isMobile',
200
- fn: function(expression, options) {
201
- if (window.innerWidth < 768) {
202
- return options.fn(expression);
203
- } else {
204
- return options.inverse(expression);
205
- }
206
- }
207
- },
208
197
  // Loop to go through and add each attribute defined in the attributes: {} object
209
198
  {
210
199
  name: 'addAttributes',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.7.7-beta.1",
3
+ "version": "3.7.8",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",