mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-12 00:05:49 +08:00
Add path argument so we can customize where settings.xml will be stored
This commit is contained in:
committed by
Slawomir Jaranowski
parent
99450b69de
commit
654e1efa2a
@ -43,6 +43,9 @@ steps:
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
```
|
||||
|
||||
Also you can use `path` argument if your settings.xml is stored in different location.
|
||||
|
||||
|
||||
All `server` attributes may be specified:
|
||||
* `id` _(required)_
|
||||
* `username`
|
||||
|
||||
@ -6,6 +6,9 @@ branding:
|
||||
color: 'green'
|
||||
|
||||
inputs:
|
||||
path:
|
||||
description: 'override default path to settings.xml which is $HOME/.m2/settings.xml'
|
||||
required: false
|
||||
servers:
|
||||
description: 'servers definition in json array, eg: [{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
required: false
|
||||
|
||||
@ -30,7 +30,12 @@ const DOMParser = require('@xmldom/xmldom').DOMParser;
|
||||
const XMLSerializer = require('@xmldom/xmldom').XMLSerializer;
|
||||
|
||||
function getSettingsPath() {
|
||||
const _path = core.getInput('path');
|
||||
if (!_path) {
|
||||
return path.join(os.homedir(), '.m2', 'settings.xml');
|
||||
} else {
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
|
||||
function getTemplate(templateName) {
|
||||
|
||||
@ -689,3 +689,18 @@ test('genereate - override', () => {
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('generate - custom path', () => {
|
||||
|
||||
if (!fs.existsSync(testHomePath)) {
|
||||
fs.mkdirSync(testHomePath);
|
||||
}
|
||||
|
||||
const mySettings = path.join(testHomePath, 'settings_custom.xml');
|
||||
process.env['INPUT_PATH'] = mySettings;
|
||||
settings.generate();
|
||||
|
||||
const settingsStatus = fs.lstatSync(mySettings);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user