mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-03 11:03:39 +00:00
b8dadb718d
This PR adds support for renovating the `node_js` versions in `.travis.yml` configuration files. Important notes: - Functionality is disabled by default and hence opt-in via configuration - Added a new manager type `node` because it is anticipated to support more than just Travis in future, with mostly unified logic - Added the config option "policy" with supported values: lts, active, current, lts_latest and lts_active - Policy is actually an array, to allow additive combining, e.g. `["lts_latest", "current"]` - Actual node versions are *hardcoded*. There is no perfect metadata source for this and they change infrequently enough that it is definitely not a problem for now (next change will be in April 2018) - If node versions need updating, they are listed from newest to oldest - Replacing function attempts to detect the indention (spacing) in file and use that To enable, configure `node.enabled=true` and optionally `node.policy=["<policy>"]` if you want something other than `lts`. Closes #1208
21 lines
607 B
JavaScript
21 lines
607 B
JavaScript
const detectIndent = require('detect-indent');
|
|
|
|
module.exports = {
|
|
setNewValue,
|
|
};
|
|
|
|
function setNewValue(currentFileContent, upgrade) {
|
|
try {
|
|
logger.debug(`node.setNewValue: ${upgrade.newVersions}`);
|
|
const indent = detectIndent(currentFileContent).indent || ' ';
|
|
let newString = `\nnode_js:\n`;
|
|
upgrade.newVersions.forEach(version => {
|
|
newString += `${indent}- '${version}'\n`;
|
|
});
|
|
return currentFileContent.replace(/\nnode_js:(\n\s+[^\n]+)+\n/, newString);
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new .travis.yml node versions');
|
|
return null;
|
|
}
|
|
}
|