Skip to content
This repository was archived by the owner on Oct 6, 2020. It is now read-only.

Commit 4add85a

Browse files
authored
Merge pull request #21 from theetrain/fix/token
fix(helper): use custom token when user provides one
2 parents ff16199 + 729bacc commit 4add85a

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

lib/helpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function hasInsertionPoint (file) {
119119

120120
if (token !== '' && String(file.contents).indexOf(token) > -1) {
121121
insertionPoint = 'token'
122+
return true
122123
} else if (token !== '' && token !== defaults.pageToken) {
123124
logger('Token not found in ' + file.relative)
124125
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<link rel="prefetch" href="asset/image1.jpg" /><link rel="prefetch" href="asset/image2.jpg" /><link rel="prefetch" href="asset/image3.png" /><link rel="prefetch" href="asset/image4.svg" />
4+
</head>
5+
<body>
6+
7+
<img src="asset/image1.jpg" alt="">
8+
<img src="asset/image2.jpg" alt="">
9+
<img src="asset/image3.png" alt="">
10+
<img src="asset/image4.svg" alt="">
11+
</body>
12+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<!--gulp-resource-hints-->
4+
</head>
5+
<body>
6+
7+
<img src="asset/image1.jpg" alt="">
8+
<img src="asset/image2.jpg" alt="">
9+
<img src="asset/image3.png" alt="">
10+
<img src="asset/image4.svg" alt="">
11+
</body>
12+
</html>

test/gulpfile.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ gulp.task('userOptionsTest', function (cb) {
6363
})
6464
})
6565

66+
gulp.task('customTokenTest', function (cb) {
67+
const testName = 'Custom Token Test'
68+
69+
return gulp.src('./fixtures/test-token*(.html)!(*-result.html)')
70+
.pipe(resourceHints({
71+
pageToken: '<!--gulp-resource-hints-->'
72+
}))
73+
.pipe(gulp.dest('./results'))
74+
.pipe(compareFiles())
75+
.on('end', () => {
76+
tap.pass(testName)
77+
})
78+
.on('error', () => {
79+
gutil.log()
80+
tap.fail(testName, 'Error on stream')
81+
})
82+
})
83+
6684
gulp.task('expectedFailures', function (cb) {
6785
const testName = 'Expected Failures'
6886

@@ -86,5 +104,5 @@ gulp.task('clean', function (cb) {
86104
})
87105

88106
gulp.task('default', ['clean'], function (cb) {
89-
sequence('defaultTest', 'userOptionsTest', 'expectedFailures')
107+
sequence('defaultTest', 'userOptionsTest', 'customTokenTest', 'expectedFailures')
90108
})

0 commit comments

Comments
 (0)