Skip to content

Commit c69cb2a

Browse files
committed
build: update gulp, replace deprecated util package
1 parent 8e021ab commit c69cb2a

6 files changed

Lines changed: 7063 additions & 954 deletions

File tree

build/createFiddleFiles.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var path = require("path"),
22
cheerio = require("cheerio"),
33
through = require("through2"),
4-
gutil = require("gulp-util"),
5-
File = gutil.File;
4+
File = require('vinyl');
65
/**
76
* Extracts HTML, JS and optionally CSS into separate files in a fiddle folder
87
* and generates an embed json config file
@@ -120,7 +119,7 @@ module.exports = function(options) {
120119
htmlFile = new File({
121120
base: file.base,
122121
path: path.join(basePath, "fiddle", "demo.html"),
123-
contents: new Buffer(html.join("\r\n"))
122+
contents: Buffer.from(html.join("\r\n"))
124123
});
125124

126125
// js
@@ -140,7 +139,7 @@ module.exports = function(options) {
140139
jsFile = new File({
141140
base: file.base,
142141
path: path.join(basePath, "fiddle", "demo.js"),
143-
contents: new Buffer(js)
142+
contents: Buffer.from(js)
144143
});
145144

146145
// css
@@ -151,7 +150,7 @@ module.exports = function(options) {
151150
cssFile = new File({
152151
base: file.base,
153152
path: path.join(basePath, "fiddle", "demo.css"),
154-
contents: new Buffer(unindentTrim(css))
153+
contents: Buffer.from(unindentTrim(css))
155154
});
156155
stream.push(cssFile);
157156
embed.embed.splice(2, 0, {
@@ -168,7 +167,7 @@ module.exports = function(options) {
168167
stream.push(new File({
169168
base: file.base,
170169
path: path.join(basePath, ".gh-embed.json"),
171-
contents: new Buffer(JSON.stringify(embed, null, 4))
170+
contents: Buffer.from(JSON.stringify(embed, null, 4))
172171
}));
173172

174173
stream.push(file);

build/localizeFiles.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var path = require("path"),
22
through = require("through2"),
3-
gutil = require("gulp-util"),
4-
File = gutil.File;
3+
File = require('vinyl');
54

65
/**
76
* Localize contents of file (resources, localization strings) and push both versions back to stream
@@ -36,14 +35,14 @@ module.exports = function(options) {
3635
file.originalPath = file.history[0];
3736
// change out path, HTMLSamples must remain in path to keep relative correct for dest
3837
file.path = path.join(basePath.replace("HTMLSamples", "HTMLSamples" + path.sep + "EN"), fileName, "index.html");
39-
file.contents = new Buffer(contentsEN, encoding);
38+
file.contents = Buffer.from(contentsEN, encoding);
4039
file.lang = "en";
4140

4241
// replace JA
4342
jaFile = new File({
4443
base: file.base,
4544
path: path.join(basePath.replace("HTMLSamples", "HTMLSamples" + path.sep + "JA"), fileName, "index.html"),
46-
contents: new Buffer(contentsJA)
45+
contents: Buffer.from(contentsJA)
4746
});
4847
jaFile.lang = "ja";
4948
jaFile.originalPath = file.originalPath;

build/updateResources.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
var path = require("path"),
2-
fs = require("fs"),
1+
var fs = require("fs"),
32
cheerio = require("cheerio"),
4-
through = require("through2"),
5-
gutil = require("gulp-util"),
6-
File = gutil.File;
3+
through = require("through2");
74

85
/**
96
* Replace resource strings (src, href) and igLoader sources. Adds Japanese locale script for JA files.
@@ -85,7 +82,7 @@ module.exports = function (options) {
8582
});
8683

8784

88-
file.contents = new Buffer($.html(), encoding);
85+
file.contents = Buffer.from($.html(), encoding);
8986

9087
stream.push(file);
9188
next();

gulpfile.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
var gulp = require("gulp"),
2-
util = require("gulp-util"),
32
localize = require("./build/localizeFiles.js"),
43
updateResources = require("./build/updateResources.js"),
54
createFiddleFiles = require("./build/createFiddleFiles.js");
65

7-
var version = util.env.version; //should be passed as --version ${TRAVIS_BRANCH}
6+
var argv = require('minimist')(process.argv.slice(2));
7+
var version = argv.version; //should be passed as --version ${TRAVIS_BRANCH}
88

99
var dist = "./dist",
1010
copySrc = [
@@ -17,24 +17,24 @@ var dist = "./dist",
1717
config = require("./build/config.json");
1818

1919
// Command line overrides:
20-
if (util.env["ignite-ui"]) {
20+
if (argv["ignite-ui"]) {
2121
// Optional override for the Ignite UI source location, can be passed as --ignite-ui "http://<ignite-ui root>"
22-
config.patterns["%%ignite-ui%%"] = util.env["ignite-ui"];
22+
config.patterns["%%ignite-ui%%"] = argv["ignite-ui"];
2323
}
2424
if (version) {
2525
config.patterns["%%ignite-ui%%"] = config.patterns["%%ignite-ui%%"].replace("latest", "20" + version + "/latest");
2626
} else {
2727
version = "latest";
2828
}
29-
if (util.env["live-url"]) {
29+
if (argv["live-url"]) {
3030
// Optional override for the live demo URL (without trailing slash). Warning: might be case-sensitive
31-
config.liveUrl = util.env["live-url"].replace(/\/$/, "");
31+
config.liveUrl = argv["live-url"].replace(/\/$/, "");
3232
}
3333

3434
config.version = version.toString();
3535
dist = dist + "/" + version;
3636

37-
gulp.task("process-files", function () {
37+
gulp.task("process-files", () => {
3838
console.log("Building samples for: ", version);
3939
console.log("Ignite UI source root: ", config.patterns["%%ignite-ui%%"]);
4040
console.log("Live URL base: ", config.liveUrl);
@@ -46,7 +46,9 @@ gulp.task("process-files", function () {
4646
.pipe(gulp.dest(dist));
4747
});
4848

49-
gulp.task("build-samples", ["process-files"], function () {
49+
gulp.task("copy-static-files", () => {
5050
return gulp.src(copySrc, { base: "./" })
5151
.pipe(gulp.dest("./dist"));
52-
});
52+
});
53+
54+
gulp.task("build-samples", gulp.series("process-files", "copy-static-files"));

0 commit comments

Comments
 (0)