2024-08-22 11:48:02 +08:00
|
|
|
import { exec } from 'child_process';
|
|
|
|
|
2024-07-30 23:35:52 +08:00
|
|
|
export const Sleep = (ms:number)=> {
|
|
|
|
return new Promise(resolve=>setTimeout(resolve, ms))
|
2024-08-22 11:48:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
2024-07-30 23:35:52 +08:00
|
|
|
}
|