mod-build 3.6.22-beta.1 → 3.6.22-beta.2

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.
@@ -3,6 +3,8 @@ var request = require('request');
3
3
  var source = require('vinyl-source-stream');
4
4
  var replace = require('gulp-replace');
5
5
 
6
+ var images = [];
7
+
6
8
  function streamToDestination(gulp, siteSettings, url, fileName) {
7
9
  return new Promise(resolve => { // eslint-disable-line no-undef
8
10
  request(url)
@@ -10,7 +12,7 @@ function streamToDestination(gulp, siteSettings, url, fileName) {
10
12
  if (resp.statusCode !== 200 && resp.statusCode !== 206) {
11
13
  throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
12
14
  } else {
13
- replaceImgSrc(gulp, siteSettings, fileName);
15
+ images.push(fileName);
14
16
  }
15
17
  })
16
18
  .pipe(source(fileName))
@@ -19,12 +21,14 @@ function streamToDestination(gulp, siteSettings, url, fileName) {
19
21
  });
20
22
  }
21
23
 
22
- function replaceImgSrc(gulp, siteSettings, fileName) {
23
- const fileRegex = new RegExp(`(https?:\/\/.*${fileName})`, 'gm');
24
-
25
- return gulp.src(`${siteSettings.tmpFolder}/index.html`)
26
- .pipe(replace(fileRegex, '/resources/images/' + fileName))
27
- .pipe(gulp.dest('.'));
24
+ function replaceImagePath(gulp, siteSettings) {
25
+ var stream = gulp.src(`${siteSettings.tmpFolder}/index.html`);
26
+ if (images.length) {
27
+ images.forEach(function(image) {
28
+ stream = stream.pipe(replace(new RegExp(`(https?:\/\/.*${image})`, 'gm'), '/resources/images/' + image))
29
+ });
30
+ }
31
+ return stream.pipe(gulp.dest(siteSettings.tmpFolder))
28
32
  }
29
33
 
30
34
  const getTags = (string) => {
@@ -77,6 +81,8 @@ module.exports = function(gulp, siteSettings, siteData) {
77
81
  return streamToDestination(gulp, siteSettings, url, fileName, relativePath);
78
82
  });
79
83
 
80
- return Promise.all(urlsPromises); // eslint-disable-line no-undef
84
+ return Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
85
+ replaceImagePath(gulp, siteSettings)
86
+ })
81
87
  };
82
88
  };
@@ -8,7 +8,7 @@ module.exports.src = function(gulp, gulpPlugins, siteSettings, siteData) {
8
8
  } else if (siteData.isQSPage) {
9
9
  sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
10
10
  } else {
11
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
11
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images','grab-global-images', 'js-lint'];
12
12
  }
13
13
  runSequence(...sequenceOpts, () => {
14
14
  // Run a BrowserSync server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.22-beta.1",
3
+ "version": "3.6.22-beta.2",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"