From ba9e579b11a81e073f9400e8240a0dd4c0e33d84 Mon Sep 17 00:00:00 2001 From: "David Wilson (AZURE SDK)" Date: Fri, 22 Jan 2021 13:57:50 -0800 Subject: [PATCH] Improve resolve of AutoRest dependency path --- packages/adl/lib/cli.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/adl/lib/cli.ts b/packages/adl/lib/cli.ts index 97b5afc8d..67f360a6a 100644 --- a/packages/adl/lib/cli.ts +++ b/packages/adl/lib/cli.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import url from "url"; import yargs from "yargs"; import mkdirp from "mkdirp"; import * as path from "path"; @@ -91,16 +92,15 @@ async function main() { if (args.client) { const clientPath = path.resolve(args["output-path"], "client"); - const autoRestPath = path.resolve( - "node_modules/.bin", + const autoRestBin = process.platform === "win32" ? "autorest.cmd" : "autorest" - ); + const autoRestPath = new url.URL(`../../node_modules/.bin/${autoRestBin}`, import.meta.url); // Execute AutoRest on the output file // TODO: Parameterize client language selection - spawnSync(autoRestPath, [ + spawnSync(url.fileURLToPath(autoRestPath), [ "--version:3.0.6367", "--typescript", `--clear-output-folder=true`,