diff --git a/packages/steps/bin/set-env b/packages/steps/bin/set-env index 4fefb639..8006ce06 100755 --- a/packages/steps/bin/set-env +++ b/packages/steps/bin/set-env @@ -20,4 +20,4 @@ if [[ "$NAME" == *"="* ]]; then exit 1 fi -echo -n $VALUE > $__EXPO_STEPS_ENVS_DIR/$NAME +echo -n "$VALUE" > $__EXPO_STEPS_ENVS_DIR/$NAME diff --git a/packages/steps/src/BuildStep.ts b/packages/steps/src/BuildStep.ts index 5d428cbe..0e6358fc 100644 --- a/packages/steps/src/BuildStep.ts +++ b/packages/steps/src/BuildStep.ts @@ -28,6 +28,7 @@ import { BuildStepEnv } from './BuildStepEnv.js'; import { BuildRuntimePlatform } from './BuildRuntimePlatform.js'; import { jsepEval } from './utils/jsepEval.js'; import { interpolateJobContext } from './interpolation.js'; +import { fixEscapeCharactersInRawEnvValue } from './utils/envUtils.js'; export enum BuildStepStatus { NEW = 'new', @@ -484,7 +485,8 @@ export class BuildStep extends BuildStepOutputAccessor { const entries = await Promise.all( filenames.map(async (basename) => { const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8'); - return [basename, rawContents]; + const updatedContents = fixEscapeCharactersInRawEnvValue(rawContents); + return [basename, updatedContents]; }) ); this.ctx.global.updateEnv({ diff --git a/packages/steps/src/utils/envUtils.ts b/packages/steps/src/utils/envUtils.ts new file mode 100644 index 00000000..2c22a433 --- /dev/null +++ b/packages/steps/src/utils/envUtils.ts @@ -0,0 +1,17 @@ +export function fixEscapeCharactersInRawEnvValue(rawValue: string): string { + const escapeCharsMatches = rawValue.match(/\\(\w)/g); + let updatedValue = rawValue; + for (const match of escapeCharsMatches ?? []) { + if (match[1] === 'n') { + updatedValue = updatedValue.replace(`${match[0]}${match[1]}`, '\n'); + } + if (match[1] === 't') { + updatedValue = updatedValue.replace(`${match[0]}${match[1]}`, '\t'); + } + if (match[1] === 'r') { + updatedValue = updatedValue.replace(`${match[0]}${match[1]}`, '\r'); + } + } + + return updatedValue; +}