-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from evilebottnawi/url/resolve
Resolve relative paths as urls
- Loading branch information
Showing
8 changed files
with
12,690 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
const favicons = require('../src'); | ||
const test = require('ava'); | ||
const path = require('path'); | ||
const favicons = require("../src"); | ||
const test = require("ava"); | ||
|
||
test.cb('should generate the expected default result', t => { | ||
t.plan(1); | ||
const { logo, normalize } = require("./util"); | ||
|
||
favicons(path.join(__dirname, 'logo.png'), {}, (error, response) => { | ||
test.cb("should generate the expected default result", t => { | ||
t.plan(1); | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
favicons(logo, {}, (error, result) => { | ||
if (error) { | ||
throw error; | ||
} | ||
|
||
const result = [...response.files, ...response.images].reduce( | ||
(obj, {name, contents}) => Object.assign(obj, {[name]: contents}), | ||
{'index.html': response.html} | ||
); | ||
|
||
t.snapshot(result); | ||
t.end(); | ||
}); | ||
t.snapshot(normalize(result)); | ||
t.end(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const favicons = require('../src'); | ||
const test = require('ava'); | ||
|
||
const {logo, normalize} = require('./util'); | ||
|
||
test('should allow setting an URL prefix', async t => { | ||
t.plan(1); | ||
|
||
const result = await favicons(logo, { | ||
path: 'https://domain/subdomain', | ||
}); | ||
|
||
t.snapshot(normalize(result)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
const favicons = require('../src'); | ||
const test = require('ava'); | ||
const path = require('path'); | ||
const favicons = require("../src"); | ||
const test = require("ava"); | ||
|
||
test('should return a promise if callback is undefined', t => { | ||
t.plan(1); | ||
const { logo, normalize } = require("./util"); | ||
|
||
return favicons(path.join(__dirname, 'logo.png'), {}).then(response => { | ||
const result = [...response.files, ...response.images].reduce( | ||
(obj, {name, contents}) => Object.assign(obj, {[name]: contents}), | ||
{'index.html': response.html} | ||
); | ||
test("should return a promise if callback is undefined", t => { | ||
t.plan(1); | ||
|
||
t.snapshot(result); | ||
}); | ||
return favicons(logo, {}).then(result => { | ||
t.snapshot(normalize(result)); | ||
}); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
const favicons = require('../src').stream; | ||
const test = require('ava'); | ||
const path = require('path'); | ||
const gulp = require('gulp'); | ||
const favicons = require("../src").stream; | ||
const test = require("ava"); | ||
const gulp = require("gulp"); | ||
|
||
test.cb('should provide stream interface', t => { | ||
t.plan(1); | ||
const { logo } = require("./util"); | ||
|
||
const result = {}; | ||
test.cb("should provide stream interface", t => { | ||
t.plan(1); | ||
|
||
gulp.src(path.join(__dirname, 'logo.png')) | ||
.pipe(favicons({ html: 'index.html', pipeHTML: true })) | ||
.on('data', chunk => result[chunk.path] = chunk.contents) | ||
.on('end', () => { | ||
t.snapshot(result); | ||
t.end(); | ||
}); | ||
const result = {}; | ||
|
||
gulp | ||
.src(logo) | ||
.pipe(favicons({ html: "index.html", pipeHTML: true })) | ||
.on("data", chunk => (result[chunk.path] = chunk.contents)) | ||
.on("end", () => { | ||
t.snapshot(result); | ||
t.end(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const path = require("path"); | ||
|
||
module.exports.logo = path.resolve(__dirname, "logo.png"); | ||
|
||
module.exports.normalize = ({ files, images, html }) => | ||
[...files, ...images].reduce( | ||
(obj, { name, contents }) => Object.assign(obj, { [name]: contents }), | ||
{ "index.html": html } | ||
); |