mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-12 00:05:49 +08:00
fix xpath
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -14,6 +14,6 @@ jobs:
|
||||
with:
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
properties: '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
sonatype-snapshots: true
|
||||
sonatypeSnapshots: true
|
||||
|
||||
- run: cat ~/.m2/settings.xml
|
||||
|
||||
@ -34,7 +34,7 @@ Create ```settings.xml``` with https://oss.sonatype.org/content/repositories/sna
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v1
|
||||
with:
|
||||
sonatype-snapshots: true
|
||||
sonatypeSnapshots: true
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
@ -8,7 +8,7 @@ inputs:
|
||||
properties:
|
||||
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||
required: false
|
||||
sonatype-snapshots:
|
||||
sonatypeSnapshots:
|
||||
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
|
||||
default: "false"
|
||||
required: false
|
||||
|
||||
@ -40,3 +40,15 @@ test('run with default values', () => {
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
})
|
||||
|
||||
test('run with all feature', () => {
|
||||
|
||||
process.env['INPUT_SERVERES'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
process.env['INPUT_SONATYPESNAPSHOT'] = true;
|
||||
|
||||
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
})
|
||||
|
||||
@ -66,6 +66,7 @@ function fillProperties(template) {
|
||||
.select(`/settings/profiles/profile[id[contains(text(),"_properties_")]]/properties`, template)[0];
|
||||
|
||||
JSON.parse(properties).forEach((property) => {
|
||||
|
||||
for (const key in property) {
|
||||
const keyXml = template.createElement(key);
|
||||
keyXml.textContent = property[key];
|
||||
@ -75,7 +76,7 @@ function fillProperties(template) {
|
||||
}
|
||||
|
||||
function addSonatypeSnapshots(template) {
|
||||
const val = core.getInput('sonatype-snapshots');
|
||||
const val = core.getInput('sonatypeSnapshots');
|
||||
if (val && val.toLocaleLowerCase() == 'true') {
|
||||
activateProfile(template, '_sonatype-snapshots_')
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ test('fillServers two servers', () => {
|
||||
|
||||
test('addSonatypeSnapshots activate', () => {
|
||||
|
||||
process.env['INPUT_SONATYPE-SNAPSHOTS'] = "true";
|
||||
process.env['INPUT_SONATYPESNAPSHOTS'] = "true";
|
||||
|
||||
settings.addSonatypeSnapshots(xmlTestProfile);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<settings>
|
||||
|
||||
<interactiveMode>false</interactiveMode>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user