From 5cf04033c1a66faac76eb6c0ea6519f68d4632c0 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Sat, 4 Apr 2020 12:17:00 -0700 Subject: [PATCH] Use sync callback --- dist/index.js | 27 ++++++++++++++++----------- package.json | 2 +- src/main.ts | 23 ++++++++++++++--------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/dist/index.js b/dist/index.js index a42ab73..ff6d07e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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) { - foundToolPath = files[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); diff --git a/package.json b/package.json index 6040576..2af12b9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.ts b/src/main.ts index 3a02a5e..7faa639 100644 --- a/src/main.ts +++ b/src/main.ts @@ -59,17 +59,22 @@ async function run(): Promise { 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` - if (files?.length > 0) { - foundToolPath = files[0] - } + /* 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 */ } }