fix(misc): nx wrapper should work better on windows (#26460)
!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior - wrapper echo's its contents - wrapper doesn't exit properly - wrapper has LF line endings ## Expected Behavior - wrapper is silent - wrapper exits early - wrapper has CRLF endings ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26254
This commit is contained in:
parent
4989865978
commit
55197fb33f
@ -77,6 +77,12 @@
|
||||
"version": "19.2.0-beta.2",
|
||||
"description": "Updates the default workspace data directory to .nx/workspace-data",
|
||||
"implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory"
|
||||
},
|
||||
"19-2-2-update-nx-wrapper": {
|
||||
"cli": "nx",
|
||||
"version": "19.2.2-beta.0",
|
||||
"description": "Updates the nx wrapper.",
|
||||
"implementation": "./src/migrations/update-17-3-0/update-nxw"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,18 +19,37 @@ const NODE_MISSING_ERR =
|
||||
const NPM_MISSING_ERR =
|
||||
'Nx requires npm to be available. To install NodeJS and NPM, see: https://nodejs.org/en/download/ .';
|
||||
|
||||
const BATCH_SCRIPT_CONTENTS = `set path_to_root=%~dp0
|
||||
WHERE node >nul 2>nul
|
||||
IF %ERRORLEVEL% NEQ 0 (ECHO ${NODE_MISSING_ERR}; EXIT 1)
|
||||
WHERE npm >nul 2>nul
|
||||
IF %ERRORLEVEL% NEQ 0 (ECHO ${NPM_MISSING_ERR}; EXIT 1)
|
||||
node ${path.win32.join('%path_to_root%', nxWrapperPath(path.win32))} %*`;
|
||||
const BATCH_SCRIPT_CONTENTS = [
|
||||
// don't log command to console
|
||||
`@ECHO OFF`,
|
||||
// Prevents path_to_root from being inherited by child processes
|
||||
`SETLOCAL`,
|
||||
`SET path_to_root=%~dp0`,
|
||||
// Checks if node is available
|
||||
`WHERE node >nul 2>nul`,
|
||||
`IF %ERRORLEVEL% NEQ 0 (ECHO ${NODE_MISSING_ERR} & GOTO exit)`,
|
||||
// Checks if npm is available
|
||||
`WHERE npm >nul 2>nul`,
|
||||
`IF %ERRORLEVEL% NEQ 0 (ECHO ${NPM_MISSING_ERR} & GOTO exit)`,
|
||||
// Executes the nx wrapper script
|
||||
`node ${path.win32.join('%path_to_root%', nxWrapperPath(path.win32))} %*`,
|
||||
// Exits with the same error code as the previous command
|
||||
`:exit`,
|
||||
` cmd /c exit /b %ERRORLEVEL%`,
|
||||
].join('\r\n');
|
||||
|
||||
const SHELL_SCRIPT_CONTENTS = `#!/bin/bash
|
||||
command -v node >/dev/null 2>&1 || { echo >&2 "${NODE_MISSING_ERR}"; exit 1; }
|
||||
command -v npm >/dev/null 2>&1 || { echo >&2 "${NPM_MISSING_ERR}"; exit 1; }
|
||||
path_to_root=$(dirname $BASH_SOURCE)
|
||||
node ${path.posix.join('$path_to_root', nxWrapperPath(path.posix))} $@`;
|
||||
const SHELL_SCRIPT_CONTENTS = [
|
||||
// Execute in bash
|
||||
`#!/bin/bash`,
|
||||
// Checks if node is available
|
||||
`command -v node >/dev/null 2>&1 || { echo >&2 "${NODE_MISSING_ERR}"; exit 1; }`,
|
||||
// Checks if npm is available
|
||||
`command -v npm >/dev/null 2>&1 || { echo >&2 "${NPM_MISSING_ERR}"; exit 1; }`,
|
||||
// Gets the path to the root of the project
|
||||
`path_to_root=$(dirname $BASH_SOURCE)`,
|
||||
// Executes the nx wrapper script
|
||||
`node ${path.posix.join('$path_to_root', nxWrapperPath(path.posix))} $@`,
|
||||
].join('\n');
|
||||
|
||||
export function generateDotNxSetup(version?: string) {
|
||||
const host = new FsTree(process.cwd(), false, '.nx setup');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user