Skip to content

Commit 02a2ec7

Browse files
committed
feature: @putout/plugin-github: set-node-versions: improve
1 parent dc0a7ef commit 02a2ec7

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

.github/workflows/nodejs-pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
- 20.x
1313
- 22.x
1414
- 24.x
15+
- 25.x
1516
steps:
1617
- uses: actions/checkout@v4
1718
- uses: oven-sh/setup-bun@v1

.github/workflows/nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- 20.x
1414
- 22.x
1515
- 24.x
16+
- 25.x
1617
steps:
1718
- uses: actions/checkout@v4
1819
- uses: oven-sh/setup-bun@v1
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__putout_processor_yaml({
2+
"jobs": {
3+
"build": {
4+
"runs-on": "ubuntu-latest",
5+
"strategy": {
6+
"matrix": {
7+
"node-version": [
8+
"20.x",
9+
"22.x",
10+
"24.x",
11+
"25.x"
12+
]
13+
}
14+
}
15+
}
16+
}
17+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
__putout_processor_yaml({
2+
"jobs": {
3+
"build": {
4+
"runs-on": "ubuntu-latest",
5+
"strategy": {
6+
"matrix": {
7+
"node-version": ["20.x", "24.x"]
8+
}
9+
}
10+
}
11+
}
12+
});

packages/plugin-github/lib/set-node-versions/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const traverse = ({push, options}) => ({
3838
const {__object} = getTemplateValues(path, __yaml);
3939

4040
for (const nodeVersionPath of traverseProperties(__object, 'node-version')) {
41+
let is = false;
4142
const valueStr = nodeVersionPath.get('value').toString();
4243

4344
const versions = parse(valueStr);
@@ -54,12 +55,15 @@ export const traverse = ({push, options}) => ({
5455
for (const currentVersion of versions) {
5556
const [current] = currentVersion.split('.');
5657

57-
if (current === nodeVersion)
58-
return;
58+
if (current !== nodeVersion) {
59+
is = true;
60+
break;
61+
}
5962
}
6063
}
6164

62-
push(nodeVersionPath.get('value'));
65+
if (is)
66+
push(nodeVersionPath.get('value'));
6367
}
6468
},
6569
});

packages/plugin-github/lib/set-node-versions/index.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ test('plugin-github: set node versions: no transform: no-version', (t) => {
3232
t.end();
3333
});
3434

35+
test('plugin-github: set node versions: transform: overlap', (t) => {
36+
t.transform('overlap');
37+
t.end();
38+
});
39+
40+
test('plugin-github: set node versions: report: overlap', (t) => {
41+
t.report('overlap', ['Use latest version of node']);
42+
t.end();
43+
});
44+
3545
test('plugin-github: set node versions: no report with options: intersects', (t) => {
3646
t.noReportWithOptions('intersects', {
3747
versions: ['24.x'],

0 commit comments

Comments
 (0)