-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fae6396
commit 5ff897a
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const os = require('os'); | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
|
||
exports.register = async (fixers) => { | ||
const { stdout, stderr } = await exec('gvm listall'); | ||
if (stderr) { | ||
throw stderr; | ||
} | ||
|
||
const patchVersionReplacements = {}; | ||
for (const line of stdout.split('\n').slice(1,-1)) { | ||
const match = line.trim().match(/^go(\d+\.\d+\.)(\d+)$/); | ||
if (!match) { | ||
continue; | ||
} | ||
|
||
const pattern = match[1].replace(/\./g, '\\.') + '[0-9][0-9]*'; | ||
patchVersionReplacements[pattern] = 'go' + match[1] + match[2]; | ||
} | ||
|
||
fixers[0].push({ | ||
id: 'update-lang-go', | ||
cmd: Object.keys(patchVersionReplacements).map(pattern => { | ||
return `sed ${os.type() === 'Darwin' ? '-i "" -E' : '-i -e'} "s/\\(GO_VERSION.*\\)${pattern}/\\1${patchVersionReplacements[pattern]}/g" chunks/lang-go/chunk.yaml`; | ||
}).join('\n'), | ||
description: 'update lang go', | ||
}); | ||
}; |