Skip to content

Commit f343c65

Browse files
committed
wip
1 parent 39d6675 commit f343c65

File tree

14 files changed

+1027
-36
lines changed

14 files changed

+1027
-36
lines changed

bin/formidablejs/Commands/Build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Build extends Command {
8484

8585
workerThreadErrors = true;
8686

87-
return Output.write(" <bg:yellow> WARN </bg:yellow> Bun does not support node.js worker_threads yet.\n");
87+
return Output.write(" <bg:yellow> WARN </bg:yellow> Bun does not support Node.js worker_threads yet.\n");
8888
}
8989

9090
process.stdout.write(data);

bin/formidablejs/runtime.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
const getRuntime = () => {
2-
const args = process.argv;
2+
const path = process.argv[0];
33
let runtime = 'node';
44

5-
if (args) {
6-
const executor = args[0].split('/').pop();
5+
if (path) {
6+
const isWindows = path.endsWith('.exe');
7+
const separator = isWindows ? '\\' : '/';
8+
let executor = path.split(separator).slice(-1)[0];
79

8-
if (executor != undefined) {
10+
if (isWindows) {
11+
executor = executor.slice(0, -4);
12+
}
13+
14+
if (executor) {
915
runtime = executor;
1016
}
1117
}
1218

1319
return runtime;
14-
}
20+
};
1521

16-
module.exports = { getRuntime }
22+
module.exports = { getRuntime };

bin/imba/server.imba

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,33 @@ import { Kernel } from '@formidablejs/framework'
33
import { join } from 'path'
44
import { execSync } from 'child_process'
55
import { writeFileSync, existsSync } from 'fs-extra'
6+
import { serve } from './server/serve'
67

78
const { app } = require('../../../../../bootstrap/main')
89

910
const application = app.initiate(app.make(Kernel), true)
1011

1112
application.then do(instance)
13+
const runtime = do
14+
const args = process.argv
15+
let runtime = 'node'
16+
17+
if args && args.length > 0
18+
const executor = args[0].split('/').pop!
19+
20+
runtime = executor if executor != undefined
21+
22+
runtime
23+
1224
const start = do
1325
let port = process.env.PORT || 3000
1426
let host = process.env.HOST || 'localhost'
1527
let addr = process.env.ADDR || false
1628

17-
imba.serve instance.fastify().server
29+
if runtime! == 'bun'
30+
serve instance.fastify().server
31+
else
32+
imba.serve instance.fastify().server
1833

1934
instance.fastify().listen({
2035
port: Number(port),

bin/imba/server/env.imba

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# imba$stdlib=1
2+
import np from 'path'
3+
4+
export const env = new class Env
5+
6+
# TODO: remove pm2 hack
7+
# when launching pm2 with an ecosystem file,
8+
# process.argv[1] is ProcessContainerFork.js
9+
# the problem with using process.env.pm_exec_path is if the shell is inherited
10+
# from another process that was started with pm2, the pm_exec_path environment variable
11+
# will also be inherited, which may or may not be a completely different path.
12+
get rootDir
13+
process.env.IMBA_OUTDIR or np.dirname(process.env.pm_exec_path or process.argv[1])
14+
15+
get publicPath
16+
np.resolve(rootDir,process.env.IMBA_PUBDIR or global.IMBA_PUBDIR or 'public')

0 commit comments

Comments
 (0)