mod-build 3.6.22-beta.1 → 3.6.22-beta.3
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/gulp-tasks/grab-global-images.js +34 -15
- package/gulp-tasks/serve.js +1 -1
- package/package.json +1 -1
|
@@ -3,28 +3,48 @@ 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) {
|
|
9
|
+
var finalDestination;
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
12
|
+
finalDestination = siteSettings.srcFolder;
|
|
13
|
+
} else {
|
|
14
|
+
finalDestination = siteSettings.distFolder;
|
|
15
|
+
}
|
|
16
|
+
|
|
7
17
|
return new Promise(resolve => { // eslint-disable-line no-undef
|
|
8
18
|
request(url)
|
|
9
19
|
.on('response', resp => {
|
|
10
20
|
if (resp.statusCode !== 200 && resp.statusCode !== 206) {
|
|
11
21
|
throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
|
|
12
22
|
} else {
|
|
13
|
-
|
|
23
|
+
images.push(fileName);
|
|
14
24
|
}
|
|
15
25
|
})
|
|
16
26
|
.pipe(source(fileName))
|
|
17
|
-
.pipe(gulp.dest(`${
|
|
27
|
+
.pipe(gulp.dest(`${finalDestination}/resources/images/`))
|
|
18
28
|
.on('finish', resolve);
|
|
19
29
|
});
|
|
20
30
|
}
|
|
21
31
|
|
|
22
|
-
function
|
|
23
|
-
|
|
32
|
+
function replaceImagePath(gulp, siteSettings) {
|
|
33
|
+
var finalDestination;
|
|
34
|
+
var stream = gulp.src(`${finalDestination}/index.html`);
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
37
|
+
finalDestination = siteSettings.tmpFolder;
|
|
38
|
+
} else {
|
|
39
|
+
finalDestination = siteSettings.distFolder;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (images.length) {
|
|
43
|
+
images.forEach(function(image) {
|
|
44
|
+
stream = stream.pipe(replace(new RegExp(`"(?:(?!"|")[\\s\\S])+(${image})"`, 'gm'), '"/resources/images/' + image + '"'))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return stream.pipe(gulp.dest(finalDestination))
|
|
28
48
|
}
|
|
29
49
|
|
|
30
50
|
const getTags = (string) => {
|
|
@@ -67,16 +87,15 @@ const parseImageSources = (gulp, siteSettings) => {
|
|
|
67
87
|
};
|
|
68
88
|
|
|
69
89
|
module.exports = function(gulp, siteSettings, siteData) {
|
|
70
|
-
return function() {
|
|
71
|
-
const { isWhiteLabel } = siteData;
|
|
90
|
+
return async function() {
|
|
72
91
|
const urls = parseImageSources(gulp, siteSettings);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const relativePath = ouputPath + url.replace(fileName, '');
|
|
77
|
-
return streamToDestination(gulp, siteSettings, url, fileName, relativePath);
|
|
92
|
+
const urlsPromises = urls.map(async(url) => {
|
|
93
|
+
const fileName = await url.slice(url.lastIndexOf('/') + 1);
|
|
94
|
+
return await streamToDestination(gulp, siteSettings, url, fileName);
|
|
78
95
|
});
|
|
79
96
|
|
|
80
|
-
return Promise.all(urlsPromises)
|
|
97
|
+
return await Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
|
|
98
|
+
replaceImagePath(gulp, siteSettings)
|
|
99
|
+
})
|
|
81
100
|
};
|
|
82
101
|
};
|
package/gulp-tasks/serve.js
CHANGED
|
@@ -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
|