A new start

This commit is contained in:
2018-11-24 14:43:59 +01:00
commit 3c32c8a37a
24054 changed files with 1376258 additions and 0 deletions
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<div>This is a test</div>
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<div>This is a test<div>
<div>This is a test<div>
<div>This is a test<div>
<div>This is a test<div>
<!-- =require test.html -->
<!-- = this is a comment without an include that happens to match -->
</body>
</html>
+3
View File
@@ -0,0 +1,3 @@
// basic-include.js
// b.js
// c.js
+25
View File
@@ -0,0 +1,25 @@
/*
This is a big dummy project file to test out lots of features of gulp-include
working together in harmony.
*/
/*
I'm going to be crazy and import some files inline here in a list.
// b.js
// c.js
//=require deep_path/b.js
//=require deep_path/deeper_path/c.js
// b.js
// c.js
//=require deep_path/b.js
//=require deep_path/deeper_path/c.js
// b.js
// c.js
#=require deep_path/b.js
#=require deep_path/deeper_path/c.js
*/
// This is an inline comment
// Tree inclusion
// b.js
// c.js
+4
View File
@@ -0,0 +1,4 @@
// include-path a.js
// include-path b.js
// another include path file
// third include path file
+3
View File
@@ -0,0 +1,3 @@
// include-trees.js
// b.js
// c.js
+5
View File
@@ -0,0 +1,5 @@
// options-extensions.js
//=include deep_path/b.js
/*
Lorem ipsum
/*
+8
View File
@@ -0,0 +1,8 @@
// Recursive inclusion
// recursive-one.js
// b.js
// c.js
// recursive-two.js
// recursive-three.js
// Above should be b.js and c.js
+15
View File
@@ -0,0 +1,15 @@
// whitespace.js
// b.js
// c.js
// 2 spaces over
// 4 spaces over
// No spaces over
// 8 spaces over
// Should be indented below
// 2 spaces over
// 4 spaces over
// No spaces over
// 8 spaces over
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<!--=include test-with-unicode-BOM.html -->
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
</head>
<body>
<!--=include test.html -->
<!-- = include test.html -->
<!--=include test.html-->
<!-- =include test.html-->
<!-- =require test.html -->
<!-- = this is a comment without an include that happens to match -->
</body>
</html>
@@ -0,0 +1 @@
<div>This is a test</div>
+1
View File
@@ -0,0 +1 @@
<div>This is a test<div>
+3
View File
@@ -0,0 +1,3 @@
// basic-include.js
/*= include deep_path/b.js */
// = include "deep_path/deeper_path/c.js"
+24
View File
@@ -0,0 +1,24 @@
/*
This is a big dummy project file to test out lots of features of gulp-include
working together in harmony.
*/
/*
I'm going to be crazy and import some files inline here in a list.
//=include deep_path/b.js
//=include deep_path/deeper_path/c.js
//=require deep_path/b.js
//=require deep_path/deeper_path/c.js
//=include deep_path/b.js
//=include deep_path/deeper_path/c.js
//=require deep_path/b.js
//=require deep_path/deeper_path/c.js
#=include deep_path/b.js
#=include deep_path/deeper_path/c.js
#=require deep_path/b.js
#=require deep_path/deeper_path/c.js
*/
// This is an inline comment
// Tree inclusion
//=include deep_path/**/*.js
+1
View File
@@ -0,0 +1 @@
// b.js
@@ -0,0 +1 @@
// c.js
+1
View File
@@ -0,0 +1 @@
Lorem ipsum
+1
View File
@@ -0,0 +1 @@
//=include this-path-does-not-exist.js
+4
View File
@@ -0,0 +1,4 @@
//= include a.js
//= include deeper/b.js
//= include another-include-path.js
//= include third-include-path-file.js
+1
View File
@@ -0,0 +1 @@
// include-path a.js
+1
View File
@@ -0,0 +1 @@
// include-path b.js
@@ -0,0 +1 @@
// another include path file
@@ -0,0 +1 @@
// third include path file
+2
View File
@@ -0,0 +1,2 @@
// include-trees.js
//=include deep_path/**/*.js
+5
View File
@@ -0,0 +1,5 @@
// options-extensions.js
//=include deep_path/b.js
/*
//=include deep_path/text.txt
/*
+4
View File
@@ -0,0 +1,4 @@
// Recursive inclusion
//=include recursive/recursive-one.js
// Above should be b.js and c.js
@@ -0,0 +1 @@
// recursive-three.js
@@ -0,0 +1,2 @@
// recursive-two.js
//=include deepest/recursive-three.js
@@ -0,0 +1,4 @@
// recursive-one.js
//= include ../deep_path/b.js
//= include ../deep_path/deeper_path/c.js
//= include deeper/recursive-two.js
+7
View File
@@ -0,0 +1,7 @@
// whitespace.js
//= include deep_path/b.js
//= include deep_path/deeper_path/c.js
//=include whitespace/a.js
// Should be indented below
//=include whitespace/a.js
+5
View File
@@ -0,0 +1,5 @@
// 2 spaces over
// 4 spaces over
// No spaces over
// 8 spaces over
+234
View File
@@ -0,0 +1,234 @@
var gutil = require("gulp-util"),
should = require("should"),
include = require("../index"),
fs = require("fs"),
vm = require("vm"),
assert = require('stream-assert'),
gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
path = require("path");
// TEST DESCRIPTIONS
describe("gulp-include", function () {
describe("File including", function () {
it("should replace special comments with file contents", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/basic-include.js",
contents: fs.readFileSync("test/fixtures/js/basic-include.js")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/basic-include.js"), "utf8"))
done();
});
testInclude.write(file);
});
it("should keep whitespace when including", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/whitespace.js",
contents: fs.readFileSync("test/fixtures/js/whitespace.js")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/whitespace.js"), "utf8"))
done();
});
testInclude.write(file);
});
it("should include complex folder trees", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/include-trees.js",
contents: fs.readFileSync("test/fixtures/js/include-trees.js")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/include-trees.js"), "utf8"))
done();
});
testInclude.write(file);
});
})
it("should not REQUIRE a file twice", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/big-dummy-project-file.js",
contents: fs.readFileSync("test/fixtures/js/big-dummy-project-file.js")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/big-dummy-project-file.js"), "utf8"))
done();
});
testInclude.write(file);
});
it("should pull files recursively", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/recursive.js",
contents: fs.readFileSync("test/fixtures/js/recursive.js")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/recursive.js"), "utf8"))
done();
});
testInclude.write(file);
});
it("should only include files with the set extensions, if provided", function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/options-extensions.js",
contents: fs.readFileSync("test/fixtures/js/options-extensions.js")
});
testInclude = include({
extensions: ".txt"
});
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/options-extensions.js"), "utf8"))
done();
});
testInclude.write(file);
});
it("should work with html-comments", function(done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/html/basic-include.html",
contents: fs.readFileSync("test/fixtures/html/basic-include.html")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/html/basic-include-output.html"), "utf8"))
done();
});
testInclude.write(file);
})
it('should support source maps', function (done) {
gulp.src('test/fixtures/js/basic-include.js')
.pipe(sourcemaps.init())
.pipe(include())
.pipe(assert.length(1))
.pipe(assert.first(function (d) {
d.sourceMap.sources.should.have.length(3);
d.sourceMap.file.should.eql('basic-include.js');
d.sourceMap.sources.should.eql(['basic-include.js', 'deep_path/b.js', 'deep_path/deeper_path/c.js'])
}))
.pipe(assert.end(done));
});
it('should strip unicode byte order marks from included files', function (done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/html/basic-include-with-unicode-BOM.html",
contents: fs.readFileSync("test/fixtures/html/basic-include-with-unicode-BOM.html")
});
testInclude = include();
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/html/basic-include-output-with-unicode-BOM.html"), "utf8"))
done();
});
testInclude.write(file);
})
it("should include from set includePaths", function(done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/include-path.js",
contents: fs.readFileSync("test/fixtures/js/include-path.js")
});
testInclude = include({
includePaths: [
__dirname + "/fixtures/js/include-path",
__dirname + "/fixtures/js/include-path2",
__dirname + "/fixtures/js/include-path2/deeper2",
]
});
testInclude.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(fs.readFileSync("test/expected/js/include-path.js"), "utf8"))
done();
});
testInclude.write(file);
})
it("should throw an error if no match is found with hardFail: true", function(done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/include-fail.js",
contents: fs.readFileSync("test/fixtures/js/include-fail.js")
});
testInclude = include({
hardFail: true
});
testInclude.on("error", function(err) {
if (err) done();
});
testInclude.write(file);
})
it("should not throw an error if no match is found with hardFail: false", function(done) {
var file = new gutil.File({
base: "test/fixtures/",
path: "test/fixtures/js/include-fail.js",
contents: fs.readFileSync("test/fixtures/js/include-fail.js")
});
testInclude = include({
hardFail: false
});
testInclude.on("error", function(err) {
done(err);
});
testInclude.on("data", function(newFile) {
done();
});
testInclude.write(file);
})
})