feat(utils): get vscode version message - commit id
This commit is contained in:
24
src/utils.ts
24
src/utils.ts
@@ -1,3 +1,27 @@
|
||||
import { exec } from 'child_process';
|
||||
|
||||
export const Sleep = (ms:number)=> {
|
||||
return new Promise(resolve=>setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
export function getVsCodeCommitId(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec('code --version', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject('Error occurred:' + error.message);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
reject('Error output:' + stderr);
|
||||
return;
|
||||
}
|
||||
const lines = stdout.trim().split('\n');
|
||||
if (lines.length > 1) {
|
||||
const commitId = lines[1]; // 第二行是 commit ID
|
||||
resolve(commitId);
|
||||
} else {
|
||||
reject('Unexpected output format:' + stdout);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user