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",
|
"version": "19.2.0-beta.2",
|
||||||
"description": "Updates the default workspace data directory to .nx/workspace-data",
|
"description": "Updates the default workspace data directory to .nx/workspace-data",
|
||||||
"implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory"
|
"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 =
|
const NPM_MISSING_ERR =
|
||||||
'Nx requires npm to be available. To install NodeJS and NPM, see: https://nodejs.org/en/download/ .';
|
'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
|
const BATCH_SCRIPT_CONTENTS = [
|
||||||
WHERE node >nul 2>nul
|
// don't log command to console
|
||||||
IF %ERRORLEVEL% NEQ 0 (ECHO ${NODE_MISSING_ERR}; EXIT 1)
|
`@ECHO OFF`,
|
||||||
WHERE npm >nul 2>nul
|
// Prevents path_to_root from being inherited by child processes
|
||||||
IF %ERRORLEVEL% NEQ 0 (ECHO ${NPM_MISSING_ERR}; EXIT 1)
|
`SETLOCAL`,
|
||||||
node ${path.win32.join('%path_to_root%', nxWrapperPath(path.win32))} %*`;
|
`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
|
const SHELL_SCRIPT_CONTENTS = [
|
||||||
command -v node >/dev/null 2>&1 || { echo >&2 "${NODE_MISSING_ERR}"; exit 1; }
|
// Execute in bash
|
||||||
command -v npm >/dev/null 2>&1 || { echo >&2 "${NPM_MISSING_ERR}"; exit 1; }
|
`#!/bin/bash`,
|
||||||
path_to_root=$(dirname $BASH_SOURCE)
|
// Checks if node is available
|
||||||
node ${path.posix.join('$path_to_root', nxWrapperPath(path.posix))} $@`;
|
`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) {
|
export function generateDotNxSetup(version?: string) {
|
||||||
const host = new FsTree(process.cwd(), false, '.nx setup');
|
const host = new FsTree(process.cwd(), false, '.nx setup');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user