From ee65e6a1001330a44d3d3ff8f53aad953095f956 Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Wed, 30 Nov 2022 12:55:30 -0500 Subject: [PATCH] fix(misc): nx init should allow overriding the version of nx --- packages/nx/src/command-line/init.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nx/src/command-line/init.ts b/packages/nx/src/command-line/init.ts index 0760fbc2e0783..beba35787a292 100644 --- a/packages/nx/src/command-line/init.ts +++ b/packages/nx/src/command-line/init.ts @@ -5,27 +5,28 @@ import { addNxToNpmRepo } from '../nx-init/add-nx-to-npm-repo'; export async function initHandler() { const args = process.argv.slice(2).join(' '); + const version = process.env.NX_VERSION ?? 'latest'; if (existsSync('package.json')) { if (existsSync('angular.json')) { // TODO(leo): remove make-angular-cli-faster - execSync(`npx --yes make-angular-cli-faster@latest ${args}`, { + execSync(`npx --yes make-angular-cli-faster@${version} ${args}`, { stdio: [0, 1, 2], }); } else if (isCRA()) { // TODO(jack): remove cra-to-nx - execSync(`npx --yes cra-to-nx@latest ${args}`, { + execSync(`npx --yes cra-to-nx@${version} ${args}`, { stdio: [0, 1, 2], }); } else if (isMonorepo()) { // TODO: vsavkin remove add-nx-to-monorepo - execSync(`npx --yes add-nx-to-monorepo@latest ${args}`, { + execSync(`npx --yes add-nx-to-monorepo@${version} ${args}`, { stdio: [0, 1, 2], }); } else { await addNxToNpmRepo(); } } else { - execSync(`npx --yes create-nx-workspace@latest ${args}`, { + execSync(`npx --yes create-nx-workspace@${version} ${args}`, { stdio: [0, 1, 2], }); }