Use sync callback

This commit is contained in:
Heath Stewart 2020-04-04 12:17:00 -07:00
parent f6890ff843
commit 5cf04033c1
3 changed files with 31 additions and 21 deletions

23
dist/index.js vendored
View File

@ -1950,17 +1950,22 @@ function run() {
let foundToolPath = '';
const options = {};
options.listeners = {
stdout: (data) => __awaiter(this, void 0, void 0, function* () {
var _b;
// eslint-disable-next-line prefer-const
let output = data.toString();
const pattern = `${output.trim()}\\\\MSBuild\\**\\Bin\\msbuild.exe`;
const globber = yield glob.create(pattern);
const files = yield globber.glob();
if (((_b = files) === null || _b === void 0 ? void 0 : _b.length) > 0) {
stdout: (data) => {
const output = data.toString().trim();
core.debug(`Found installation path: ${output}`);
const pattern = `${output}\\\\MSBuild\\**\\Bin\\msbuild.exe`;
/* eslint-disable @typescript-eslint/promise-function-async */
glob
.create(pattern)
.then(globber => globber.glob())
.then(files => {
var _a;
if (((_a = files) === null || _a === void 0 ? void 0 : _a.length) > 0) {
foundToolPath = files[0];
}
})
});
/* eslint-enable @typescript-eslint/promise-function-async */
}
};
// execute the find putting the result of the command in the options foundToolPath
yield exec.exec(`"${vswhereToolExe}" ${VSWHERE_EXEC}`, [], options);

View File

@ -11,7 +11,7 @@
"lint": "eslint src/**/*.ts",
"pack": "ncc build",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
"all": "npm run build && npm run format && npm run lint && npm run pack"
},
"repository": {
"type": "git",

View File

@ -59,17 +59,22 @@ async function run(): Promise<void> {
let foundToolPath = ''
const options: ExecOptions = {}
options.listeners = {
stdout: async (data: Buffer) => {
// eslint-disable-next-line prefer-const
let output = data.toString()
stdout: (data: Buffer) => {
const output = data.toString().trim()
core.debug(`Found installation path: ${output}`)
const pattern = `${output.trim()}\\\\MSBuild\\**\\Bin\\msbuild.exe`
const globber = await glob.create(pattern)
const files = await globber.glob()
const pattern = `${output}\\\\MSBuild\\**\\Bin\\msbuild.exe`
/* eslint-disable @typescript-eslint/promise-function-async */
glob
.create(pattern)
.then(globber => globber.glob())
.then(files => {
if (files?.length > 0) {
foundToolPath = files[0]
}
})
/* eslint-enable @typescript-eslint/promise-function-async */
}
}