Skip to content

Commit 6fc0a8e

Browse files
committed
Test Windows
1 parent 9cb0794 commit 6fc0a8e

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
os: [windows-2025]
10-
elasticsearch-version: [9]
9+
os: [windows-2022]
10+
elasticsearch-version: [8]
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: ./.
1414
with:
1515
elasticsearch-version: ${{ matrix.elasticsearch-version }}
16-
# plugins: |
17-
# analysis-kuromoji
18-
# analysis-smartcn
16+
plugins: |
17+
analysis-kuromoji
18+
analysis-smartcn
1919
config: |
2020
cluster.name: my-cluster
2121
http.port: 9201

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ function run() {
6060
}
6161
}
6262

63+
// only use with validated input
64+
// https://github.com/nodejs/node/issues/52554
6365
function runBat() {
6466
const args = Array.from(arguments);
6567
console.log(args.join(' '));
6668
const command = args.shift();
69+
if (!fs.existsSync(command)) {
70+
throw 'Bat not found';
71+
}
6772
const ret = spawnSync(command, args, {stdio: 'inherit', shell: true});
6873
if (ret.status !== 0) {
6974
throw ret.error;
@@ -166,7 +171,7 @@ function installPlugins() {
166171

167172
// validate
168173
plugins.forEach( function(plugin) {
169-
if (!/^\w\S+$/.test(plugin)) {
174+
if (!/^\w(\w|-)+$/i.test(plugin)) {
170175
throw `Invalid plugin: ${plugin}`;
171176
}
172177
});
@@ -176,14 +181,16 @@ function installPlugins() {
176181
const versionParts = elasticsearchVersion.split('.');
177182
const atOnce = parseInt(versionParts[0]) >= 7 && parseInt(versionParts[1]) >= 6;
178183
let pluginCmd = path.join(esHome, 'bin', 'elasticsearch-plugin');
184+
let runCmd = run;
179185
if (isWindows()) {
180-
throw 'This action does not support plugins on Windows';
186+
pluginCmd += '.bat';
187+
runCmd = runBat;
181188
}
182189
if (atOnce) {
183-
run(pluginCmd, 'install', '--silent', '--batch', ...plugins);
190+
runCmd(pluginCmd, 'install', '--silent', '--batch', ...plugins);
184191
} else {
185192
plugins.forEach( function(plugin) {
186-
run(pluginCmd, 'install', '--silent', '--batch', plugin);
193+
runCmd(pluginCmd, 'install', '--silent', '--batch', plugin);
187194
});
188195
}
189196
}

0 commit comments

Comments
 (0)