Skip to content

Commit 9dcf2bb

Browse files
committed
chore: fix CLI so it doesn't terminate immediately
1 parent a1bc8ba commit 9dcf2bb

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

apps/demo/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ tasks:
1010
command: email preview emails
1111
options:
1212
cache: false
13+
persistent: true

packages/create-mail/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ tasks:
99
build:
1010
command: echo "Build Complete ✓"
1111
inputs:
12+
- cli.js
1213
- generators
1314
- src
1415
- package.json

packages/jsx-email/cli.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ Please upgrade Node.js to a supported version: ${engines}\n`);
2222
};
2323

2424
(async () => {
25-
await checkEngine();
26-
const { run } = await import('./dist/cli/index.js');
27-
return run();
28-
})()
29-
.then(() => process.exit(0))
30-
.catch((error) => {
25+
try {
26+
await checkEngine();
27+
const { run } = await import('./dist/cli/index.js');
28+
return run();
29+
} catch (error) {
3130
danger(error);
3231
process.exit(1);
33-
});
32+
}
33+
})();

packages/jsx-email/moon.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ tasks:
1515
- ~:copy.preview
1616
- ~:copy.templates
1717
inputs:
18+
- cli.js
19+
- generators
1820
- src
1921
- package.json
22+
- tsconfig.json
2023
options:
2124
cache: false
2225
outputStyle: 'stream'

packages/jsx-email/src/cli/commands/preview.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { log } from '../../log.js';
1515
import { buildForPreview, writePreviewDataFiles } from '../helpers.js';
1616
import { reloadPlugin } from '../vite-reload.js';
1717
import { staticPlugin } from '../vite-static.js';
18-
import { watch } from '../watcher.js';
18+
19+
// import { watch } from '../watcher.js';
1920

2021
import { getTempPath } from './build.js';
2122
import {
@@ -86,8 +87,8 @@ const buildDeployable = async ({ argv, targetPath }: PreviewCommonParams) => {
8687
const getConfig = async ({ argv, targetPath }: PreviewCommonParams) => {
8788
const buildPath = await getTempPath('preview');
8889
const root = JSX_DEV_LOCAL
89-
? fileURLToPath(import.meta.resolve('../../../../../../apps/preview/app'))
90-
: fileURLToPath(import.meta.resolve('../../../preview'));
90+
? fileURLToPath(import.meta.resolve('../../../../../apps/preview/app'))
91+
: fileURLToPath(import.meta.resolve('../../preview'));
9192
const { basePath = '/', host = false, port = 55420 } = argv;
9293

9394
if (JSX_DEV_LOCAL)
@@ -180,8 +181,9 @@ export const command: CommandFn = async (argv: PreviewCommandOptions, input) =>
180181

181182
globalThis.isJsxEmailPreview = true;
182183

183-
const { files, server } = await start(common);
184-
await watch({ common, files, server });
184+
// const { files, server } = await start(common);
185+
await start(common);
186+
// await watch({ common, files, server });
185187

186188
return true;
187189
};

packages/jsx-email/src/log.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ export const getPluginLog = (name: string) =>
55
getLog({ brand: 'jsx-email', name: chalk`{bold ∵ ${name}}` } as any);
66

77
export const log = getLog({ brand: 'jsx-email' } as any);
8-
9-
log.info('test');

test/smoke/moon.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ tasks:
2222
command: playwright test -x --config playwright.dev.ts
2323
deps:
2424
- ~:install
25+
env:
26+
JSX_DEV_LOCAL: 'true'
2527
options:
2628
cache: false
2729
outputStyle: 'stream'

0 commit comments

Comments
 (0)