Skip to content

Commit

Permalink
Add autofix lang-rust (#1441)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh authored Oct 21, 2024
1 parent fea8505 commit 61942bf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .autofix/fixers/update-lang-rust.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const os = require('os');

const register = async (fixers) => {
const response = await fetch("https://api.github.com/repos/rust-lang/rust/releases/latest");
const data = await response.json();
const version = data.tag_name;

const patchVersionReplacements = {
'1\\.[0-9][0-9]*\\.[0-9][0-9]*': version,
}

fixers[0].push({
id: 'update-lang-rust',
cmd: Object.keys(patchVersionReplacements).map(pattern => {
return `sed ${os.type() === 'Darwin' ? '-i "" -E' : '-i -e'} "s/\\(RUST_VERSION.*\\)${pattern}/\\1${patchVersionReplacements[pattern]}/g" chunks/lang-rust/chunk.yaml`;
}).join('\n'),
description: 'update lang rust',
});
};

exports.register = register

0 comments on commit 61942bf

Please sign in to comment.