Skip to content

Commit e2edb9c

Browse files
authored
fix: local env hot reload (#161)
2 parents b4c612b + d760b73 commit e2edb9c

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

lib/build/dispatcher/dispatcher.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ class Dispatcher {
372372
entry: this.entry,
373373
preset: this.preset.name,
374374
mode: this.preset.mode,
375-
...(this.useNodePolyfills !== null && {
375+
...(this.useNodePolyfills && {
376376
useNodePolyfills: this.useNodePolyfills,
377377
}),
378-
...(this.useOwnWorker !== null && {
378+
...(this.useOwnWorker && {
379379
useOwnWorker: this.useOwnWorker,
380380
}),
381381
},

lib/commands/deploy.commands.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
import { join } from 'path';
22
import { createPromptModule } from 'inquirer';
3+
import { promises as fs } from 'fs';
34

45
import { Commands } from '#namespaces';
56

67
const prompt = createPromptModule();
8+
/**
9+
* Checks whether a directory exists.
10+
* @param {string} dirPath - The directory path to check.
11+
* @returns {Promise<boolean>} - Returns true if the directory exists, false otherwise.
12+
*/
13+
async function directoryExists(dirPath) {
14+
try {
15+
await fs.access(dirPath);
16+
return true;
17+
} catch {
18+
return false;
19+
}
20+
}
21+
722
/**
823
* @function
924
* @memberof Commands
@@ -40,7 +55,9 @@ async function deployCommand() {
4055

4156
const { applicationName, functionName } = answers;
4257

43-
await core.actions.uploadStatics(versionId, staticsPath);
58+
if (await directoryExists(staticsPath)) {
59+
await core.actions.uploadStatics(versionId, staticsPath);
60+
}
4461
const domain = await core.actions.deploy(applicationName, functionName);
4562
core.actions.watchPropagation(domain);
4663
}

lib/env/server.env.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,20 @@ async function handleFileChange(path, workerPath, port) {
9393
const { entry, preset, mode, useNodePolyfills, useOwnWorker } =
9494
await vulcan.readVulcanEnv('local');
9595

96+
let command = `vulcan build --entry ${entry} --preset ${preset} --mode ${mode}`;
97+
98+
if (useNodePolyfills) {
99+
command += ` --useNodePolyfills ${useNodePolyfills}`;
100+
}
101+
102+
if (useOwnWorker) {
103+
command += ` --useOwnWorker ${useOwnWorker}`;
104+
}
105+
96106
feedback.build.info(Messages.build.info.rebuilding);
97107

98108
try {
99-
await exec(
100-
`vulcan build --entry ${entry} --preset ${preset} --mode ${mode} --useNodePolyfills ${useNodePolyfills} --useOwnWorker ${useOwnWorker}`,
101-
);
109+
await exec(command);
102110
await manageServer(workerPath, port);
103111
} catch (error) {
104112
debug.error(`Build or server restart failed: ${error}`);

0 commit comments

Comments
 (0)