Skip to content

Commit b4490b8

Browse files
committed
fix: preserve dotenv parser in PM2 wrapper
1 parent f6f4d72 commit b4490b8

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/domain/deploy/dotenv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export function runWithDotenv(
1919
): string {
2020
if (!envFile) return command;
2121

22+
const encodedRunner = Buffer.from(dotenvRunner).toString('base64');
2223
const encodedEnvironment = Buffer.from(JSON.stringify(explicitEnvironment)).toString('base64url');
23-
return `node -e ${shellSingleQuote(dotenvRunner)} -- ` +
24+
return `node -e "$(printf '%s' ${shellSingleQuote(encodedRunner)} | base64 --decode)" -- ` +
2425
`${shellSingleQuote(envFile)} ${shellSingleQuote(encodedEnvironment)} bash -c ${shellSingleQuote(command)}`;
2526
}

tests/unit/backend-strategy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ describe('BackendStrategy.startApp', () => {
436436
expect(writeCmd).not.toContain('env_file:');
437437
expect(writeCmd).toContain(`script: '"'"'bash'"'"',`);
438438
expect(writeCmd).toContain('shared/.env.production');
439-
expect(writeCmd).toContain('node -e');
439+
expect(writeCmd).toContain('base64 --decode');
440440
expect(writeCmd).not.toContain('set -a');
441-
expect(writeCmd).toContain('base64url');
441+
expect(writeCmd).toContain('base64 --decode');
442442
expect(writeCmd).toContain('NODE_ENV');
443443
expect(writeCmd).toContain('3000');
444444
expect(writeCmd).toContain('exec');

tests/unit/orchestrator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('DeployOrchestrator', () => {
106106
await orchestrator.deploy({ cwd: '/test', skipBuild: false });
107107

108108
expect(captured).toBeDefined();
109-
const sourceIdx = captured!.indexOf('node -e');
109+
const sourceIdx = captured!.indexOf('base64 --decode');
110110
const userIdx = captured!.indexOf('node ace.js migration:run');
111111
expect(sourceIdx).toBeGreaterThan(-1);
112112
expect(userIdx).toBeGreaterThan(sourceIdx);

0 commit comments

Comments
 (0)