vaderjs 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.js +31 -1
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -5,16 +5,46 @@ import { Glob } from 'bun'
5
5
  const args = Bun.argv.slice(2)
6
6
  globalThis.isBuilding = false;
7
7
  import fs from 'fs'
8
+ import { spawn } from 'child_process'
8
9
  import { platform } from 'os'
9
10
  import path from 'path'
10
11
 
11
12
  let bunPath = 'bun'; // Default for Linux/Mac
12
-
13
13
  if (platform() === 'win32') {
14
14
  bunPath ='bun'; // Bun path for Windows
15
15
  } else {
16
16
  bunPath = path.resolve(process.env.HOME || process.env.USERPROFILE, '.bun', 'bin', 'bun');
17
17
  }
18
+ async function checkIfBunInstalled(){
19
+ return new Promise((resolve, reject) => {
20
+ // dont log spawn output
21
+ const install = spawn('bash', [ 'curl -fsSL https://bun.sh/install | bash && export PATH=$HOME/.bun/bin:$PATH'], {
22
+ stdio: 'ignore',
23
+ shell: true, // Allows running shell commands
24
+ });
25
+
26
+ install.on('close', (code) => {
27
+ if (code === 0) {
28
+ console.log('Bun installed successfully.');
29
+ resolve(true);
30
+ } else {
31
+ console.error('Failed to install Bun.');
32
+ reject(new Error('Bun installation failed.'));
33
+ }
34
+ });
35
+
36
+ install.on('error', (err) => {
37
+ console.error('Error during Bun installation:', err);
38
+ reject(err);
39
+ });
40
+ });
41
+ }
42
+
43
+ if(!fs.existsSync(bunPath)){
44
+ console.log('Bun is not installed, installing now...')
45
+ await checkIfBunInstalled()
46
+ }
47
+
18
48
 
19
49
 
20
50
  if (!fs.existsSync(process.cwd() + '/app') && !args.includes('init')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"