From 7cb18a88be06ea746da67d342c21cdf224771ae2 Mon Sep 17 00:00:00 2001 From: NithinU2802 Date: Sat, 2 Aug 2025 23:14:28 +0530 Subject: [PATCH 1/2] fix(create-email): correct 'shell' option type in execAsync to resolve TypeScript error in tests --- packages/create-email/src/index.spec.ts | 96 ++++++++++++------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/packages/create-email/src/index.spec.ts b/packages/create-email/src/index.spec.ts index 67b78ee99a..728be7b160 100644 --- a/packages/create-email/src/index.spec.ts +++ b/packages/create-email/src/index.spec.ts @@ -1,72 +1,72 @@ -import { spawnSync } from 'node:child_process'; +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; import { existsSync, promises as fs } from 'node:fs'; import path from 'node:path'; +import { expect, test, describe } from 'vitest'; + +const execAsync = promisify(exec); describe('automatic setup', () => { const starterPath = path.resolve(__dirname, '../.test'); + test.sequential('creation', async () => { if (existsSync(starterPath)) { await fs.rm(starterPath, { recursive: true }); } - const createEmailProcess = spawnSync( - 'node', - [path.resolve(__dirname, './index.js'), '.test'], + const { stderr, stdout } = await execAsync( + `node ${path.resolve(__dirname, './index.js')} .test`, { - shell: true, cwd: path.resolve(__dirname, '../'), - stdio: 'pipe', - }, - ); - if (createEmailProcess.stderr) { - console.log(createEmailProcess.stderr.toString()); - } - expect(createEmailProcess.status, 'starter creation should return 0').toBe( - 0, + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash' + } ); + + if (stderr) console.error(stderr); + console.log(stdout); + + expect(true).toBe(true); // Will throw if command fails }); - test.sequential('install', { timeout: 40_000 }, () => { - const installProcess = spawnSync('npm', ['install'], { - shell: true, - cwd: path.resolve(starterPath), - stdio: 'pipe', - }); - if (installProcess.stderr) { - console.log(installProcess.stderr.toString()); + test.sequential('install', { timeout: 180_000 }, async () => { + try { + const { stdout, stderr } = await execAsync('npm install', { + cwd: starterPath, + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash', + }); + console.log(stdout); + if (stderr) console.error(stderr); + } catch (err: any) { + console.error(err.stderr || err); + throw err; } - expect(installProcess.status, 'starter npm install should return 0').toBe( - 0, - ); }); - test.sequential('export', () => { - const exportProcess = spawnSync('npm', ['run export'], { - shell: true, - cwd: starterPath, - stdio: 'pipe', - }); - if (exportProcess.stderr) { - console.log(exportProcess.stderr.toString()); + test.sequential('export', { timeout: 60_000 }, async () => { + try { + const { stdout, stderr } = await execAsync('npm run export', { + cwd: starterPath, + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash' + }); + console.log(stdout); + if (stderr) console.error(stderr); + } catch (err: any) { + console.error(err.stderr || err); + throw new Error('npm run export failed'); } - expect(exportProcess.status, 'export should return status code 0').toBe(0); }); - test.sequential('type checking', { timeout: 10_000 }, () => { - const typecheckingProcess = spawnSync('npx', ['tsc'], { - shell: true, - cwd: starterPath, - stdio: 'pipe', - }); - if (typecheckingProcess.stderr) { - console.log(typecheckingProcess.stderr.toString()); - } - if (typecheckingProcess.stdout) { - console.log(typecheckingProcess.stdout.toString()); + test.sequential('type checking', { timeout: 60_000 }, async () => { + try { + const { stdout, stderr } = await execAsync('npx tsc', { + cwd: starterPath, + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash', + }); + console.log(stdout); + if (stderr) console.error(stderr); + } catch (err: any) { + console.error(err.stderr || err); + throw new Error('Type checking failed'); } - expect( - typecheckingProcess.status, - 'type checking should return status code 0', - ).toBe(0); }); }); From e76cace08ff6a3f49f10e2c12db2d1e32b3668c4 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+NithinU2802@users.noreply.github.com> Date: Sat, 2 Aug 2025 23:36:16 +0530 Subject: [PATCH 2/2] chore(create-email): apply Biome lint and formatting fixes --- packages/create-email/src/index.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/create-email/src/index.spec.ts b/packages/create-email/src/index.spec.ts index 728be7b160..702b7aa9b8 100644 --- a/packages/create-email/src/index.spec.ts +++ b/packages/create-email/src/index.spec.ts @@ -1,15 +1,15 @@ -import { exec } from 'node:child_process'; -import { promisify } from 'node:util'; import { existsSync, promises as fs } from 'node:fs'; import path from 'node:path'; -import { expect, test, describe } from 'vitest'; +import { exec } from 'node:child_process'; +import { promisify } from 'node:util'; +import { describe, expect, test } from 'vitest'; const execAsync = promisify(exec); describe('automatic setup', () => { const starterPath = path.resolve(__dirname, '../.test'); - test.sequential('creation', async () => { + test.sequential('creation', { timeout: 60_000 }, async () => { if (existsSync(starterPath)) { await fs.rm(starterPath, { recursive: true }); } @@ -18,7 +18,7 @@ describe('automatic setup', () => { `node ${path.resolve(__dirname, './index.js')} .test`, { cwd: path.resolve(__dirname, '../'), - shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash' + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash', } ); @@ -46,7 +46,7 @@ describe('automatic setup', () => { try { const { stdout, stderr } = await execAsync('npm run export', { cwd: starterPath, - shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash' + shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash', }); console.log(stdout); if (stderr) console.error(stderr);