Skip to content

Commit

Permalink
build: switch from Yarn to Bun
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Apr 20, 2024
1 parent 98ec0c3 commit ba30200
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 4,898 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
pull_request:
push:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install

- name: Run unit tests
run: bun test
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/coverage
/lib
/node_modules
.DS_Store
yarn-debug.log*
yarn-error.log*
*.tgz
*.tgz
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

42 changes: 19 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# posthtml-inline-favicon <img align="right" width="220" height="200" title="PostHTML logo" src="http://posthtml.github.io/posthtml/logo.svg">

[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Build][build]][build-badge]
[![Coverage][codecov-shield]][codecov]

`posthtml-inline-favicon` is a [PostHTML](https://github.com/posthtml/posthtml) plugin to inline favicons.

**Before:**

```html
<head>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="favicon.ico" />
</head>
```

Expand All @@ -26,41 +23,46 @@
## Install

```bash
# npm
npm i -D posthtml-inline-favicon

# pnpm
pnpm add -D posthtml-inline-favicon

# Yarn
yarn add -D posthtml-inline-favicon
# OR
npm i posthtml-inline-favicon
```

## Usage

```js
const fs = require('fs');
const posthtml = require('posthtml');
const { inlineFavicon } = require('posthtml-inline-favicon');
const fs = require("fs");
const posthtml = require("posthtml");
const { inlineFavicon } = require("posthtml-inline-favicon");

const html = fs.readFileSync('./index.html');
const html = fs.readFileSync("./index.html");

posthtml()
.use(inlineFavicon())
.process(html)
.then(result => fs.writeFileSync('./after.html', result.html));
.then((result) => fs.writeFileSync("./after.html", result.html));
```

## Options

By default, the plugin assumes that the file to process is in the same directory as the posthtml script. If not, specify the relative path to the html file in the options:

```js
const fs = require('fs');
const posthtml = require('posthtml');
const { inlineFavicon } = require('posthtml-inline-favicon');
const fs = require("fs");
const posthtml = require("posthtml");
const { inlineFavicon } = require("posthtml-inline-favicon");

const html = fs.readFileSync('./public/index.html');
const html = fs.readFileSync("./public/index.html");

posthtml()
.use(inlineFavicon({ path: 'public' }))
.use(inlineFavicon({ path: "public" }))
.process(html)
.then(result => fs.writeFileSync('./after.html', result.html));
.then((result) => fs.writeFileSync("./after.html", result.html));
```

## [Example](example)
Expand All @@ -77,9 +79,3 @@ See the [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/d

[npm]: https://img.shields.io/npm/v/posthtml-inline-favicon.svg?color=blue
[npm-url]: https://npmjs.com/package/posthtml-inline-favicon
[deps]: https://david-dm.org/posthtml/posthtml-inline-favicon.svg
[deps-url]: https://david-dm.org/posthtml/posthtml-inline-favicon
[build]: https://travis-ci.com/posthtml/posthtml-inline-favicon.svg?branch=master
[build-badge]: https://travis-ci.com/posthtml/posthtml-inline-favicon
[codecov]: https://codecov.io/gh/posthtml/posthtml-inline-favicon
[codecov-shield]: https://img.shields.io/codecov/c/github/posthtml/posthtml-inline-favicon.svg
Binary file added bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ The default behavior (no plugin options) assumes that `index.html` is located in
```js
// posthtml.config.js
runPlugin({
html: fs.readFileSync('./index.html'),
html: fs.readFileSync("./index.html"),
options: undefined,
output: './after.default.html'
output: "./after.default.html",
});
```

Expand All @@ -26,9 +26,9 @@ The custom behavior uses the `index.html` in the `public` folder.
```js
// posthtml.config.js
runPlugin({
html: fs.readFileSync('./public/index.html'),
options: { path: 'public' },
output: './after.public.html'
html: fs.readFileSync("./public/index.html"),
options: { path: "public" },
output: "./after.public.html",
});
```

Expand Down
2 changes: 1 addition & 1 deletion example/after.default.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion example/after.public.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
Binary file added example/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"devDependencies": {
"posthtml": "^0.11.4",
"posthtml-inline-favicon": "^0.1.0"
"posthtml": "^0.16.6",
"posthtml-inline-favicon": "^0.1.3"
}
}
18 changes: 9 additions & 9 deletions example/posthtml.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const fs = require('fs');
const posthtml = require('posthtml');
const { inlineFavicon } = require('posthtml-inline-favicon');
const fs = require("fs");
const posthtml = require("posthtml");
const { inlineFavicon } = require("posthtml-inline-favicon");

function runPlugin({ html, options, output }) {
posthtml()
.use(inlineFavicon(options))
.process(html)
.then(result => fs.writeFileSync(output, result.html));
.then((result) => fs.writeFileSync(output, result.html));
}

runPlugin({
html: fs.readFileSync('./index.html'),
html: fs.readFileSync("./index.html"),
options: undefined,
output: './after.default.html'
output: "./after.default.html",
});

runPlugin({
html: fs.readFileSync('./public/index.html'),
options: { path: 'public' },
output: './after.public.html'
html: fs.readFileSync("./public/index.html"),
options: { path: "public" },
output: "./after.public.html",
});
2 changes: 1 addition & 1 deletion example/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
141 changes: 0 additions & 141 deletions example/yarn.lock

This file was deleted.

Loading

0 comments on commit ba30200

Please sign in to comment.