Skip to content

Commit 6fb21d2

Browse files
authored
Merge pull request #315 from bezoerb/xmr/dev
2 parents a3af829 + 42fe4d1 commit 6fb21d2

11 files changed

+1612
-1478
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: monthly

.github/workflows/lint.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "!dependabot/**"
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
FORCE_COLOR: 2
13+
NODE: 20 # The Node.js version to run lint on
14+
15+
jobs:
16+
run:
17+
name: Lint
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Clone repository
22+
uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ env.NODE }}
30+
cache: npm
31+
32+
- name: Install npm dependencies
33+
run: npm ci
34+
35+
- name: Run lint
36+
run: npm run lint

.github/workflows/test.yml

+24-36
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,49 @@
11
name: Tests
2-
on: [push, pull_request]
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "!dependabot/**"
8+
pull_request:
9+
workflow_dispatch:
10+
311
env:
4-
CI: true
12+
FORCE_COLOR: 2
13+
NODE_COV: 20 # The Node.js version to run coveralls on
514

615
jobs:
7-
run:
16+
test:
817
name: Node ${{ matrix.node }} on ${{ matrix.os }}
918
runs-on: ${{ matrix.os }}
1019

1120
strategy:
1221
fail-fast: false
1322
matrix:
14-
node: [18,20]
23+
node: [18, 20]
1524
os: [ubuntu-latest, windows-latest]
1625

1726
steps:
1827
- name: Clone repository
19-
uses: actions/checkout@v2
28+
uses: actions/checkout@v4
29+
with:
30+
persist-credentials: false
2031

2132
- name: Set up Node.js
22-
uses: actions/setup-node@v1
33+
uses: actions/setup-node@v4
2334
with:
2435
node-version: ${{ matrix.node }}
25-
26-
- run: node --version
27-
- run: npm --version
28-
29-
- name: Set up npm cache
30-
uses: actions/cache@v2
31-
with:
32-
path: ~/.npm
33-
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
34-
restore-keys: |
35-
${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
36-
${{ runner.OS }}-node-v${{ matrix.node }}-
36+
architecture: ${{ matrix.architecture }}
37+
cache: npm
3738

3839
- name: Install npm dependencies
3940
run: npm ci
4041

4142
- name: Run tests
42-
run: npm test
43+
run: npm run jest
4344

44-
- name: Coveralls Parallel
45-
uses: coverallsapp/github-action@master
46-
env:
47-
NODE_COVERALLS_DEBUG: 1
45+
- name: Run Coveralls
46+
uses: coverallsapp/github-action@v2
47+
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV
4848
with:
49-
github-token: ${{ secrets.github_token }}
50-
flag-name: run-${{ matrix.os }}-${{ matrix.node }}
51-
parallel: true
52-
53-
finish:
54-
needs: run
55-
runs-on: ubuntu-latest
56-
steps:
57-
- name: Coveralls Finished
58-
uses: coverallsapp/github-action@master
59-
with:
60-
github-token: ${{ secrets.github_token }}
61-
parallel-finished: true
49+
github-token: "${{ secrets.GITHUB_TOKEN }}"

cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,15 @@ function run(data) {
155155
}
156156
}
157157

158-
(cli.input || []).forEach((file) => {
158+
for (const file of cli.input || []) {
159159
const temporary = read(file);
160160
try {
161161
parse(temporary);
162162
options_.css = temporary;
163163
} catch {
164164
options_.html = temporary;
165165
}
166-
});
166+
}
167167

168168
if (!options_.html || !options_.css) {
169169
cli.showHelp();

index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function inline(html, styles, options) {
107107
);
108108

109109
// Add link tags before old links
110-
o.replaceStylesheets.forEach((href) => {
110+
for (const href of o.replaceStylesheets) {
111111
const link = document.createElement('link');
112112

113113
link.setAttribute('rel', 'stylesheet');
@@ -139,26 +139,26 @@ export function inline(html, styles, options) {
139139
document.remove(link);
140140
}
141141
}
142-
});
142+
}
143143

144144
// Remove old links
145-
removable.forEach((link) => {
145+
for (const link of removable) {
146146
if (link.parentElement.tagName === 'NOSCRIPT') {
147147
document.remove(link.parentElement);
148148
} else {
149149
document.remove(link);
150150
}
151-
});
151+
}
152152
} else {
153153
// Modify links and add clones to noscript block
154-
links.forEach((link) => {
154+
for (const link of links) {
155155
const href = link.getAttribute('href');
156156
const media = link.getAttribute('media');
157157
const type = link.getAttribute('type');
158158
const integrity = link.getAttribute('integrity');
159159

160160
if (['print', 'speech'].includes(media)) {
161-
return;
161+
continue;
162162
}
163163

164164
if (o.extract) {
@@ -218,7 +218,7 @@ export function inline(html, styles, options) {
218218
document.remove(link);
219219
}
220220
}
221-
});
221+
}
222222
}
223223

224224
return Buffer.from(document.serialize());

jest.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const config = {
2+
coverageProvider: 'v8',
3+
coverageReporters: ['html', 'lcov', 'text'],
4+
collectCoverageFrom: ['cli.js', 'index.js', 'src/*.js', '!**/node_modules/**'],
5+
roots: [''],
6+
};
7+
8+
export default config;

0 commit comments

Comments
 (0)