Skip to content

Commit 2b154e3

Browse files
committed
change bin if windows
1 parent 9d4d600 commit 2b154e3

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

bin/pm2

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
#!/usr/bin/env node
1+
#!/bin/sh
22

3-
require('../lib/binaries/CLI.js');
3+
SCRIPT_PATH="$(dirname "$0")/../lib/binaries/CLI.js"
4+
5+
# Check if 'bun' is available, otherwise use 'node'
6+
if command -v bun >/dev/null 2>&1
7+
then
8+
bun "$SCRIPT_PATH" "$@"
9+
else
10+
node "$SCRIPT_PATH" "$@"
11+
fi

bin/pm2-windows

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../lib/binaries/CLI.js');

bun.lockb

-1.13 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
"scripts": {
102102
"test:unit": "bash test/unit.sh",
103103
"test:e2e": "bash test/e2e.sh",
104-
"test": "bash test/unit.sh && bash test/e2e.sh"
104+
"test": "bash test/unit.sh && bash test/e2e.sh",
105+
"preinstall": "node ./preinstall.js"
105106
},
106107
"keywords": [
107108
"cli",

preinstall.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// Determine platform
5+
const isWindows = process.platform === 'win32';
6+
7+
if (!isWindows)
8+
process.exit(0)
9+
10+
const sourceFile = 'bin/pm2-windows';
11+
const destinationFile = 'bin/pm2';
12+
13+
// Resolve file paths
14+
const sourcePath = path.resolve(__dirname, sourceFile);
15+
const destinationPath = path.resolve(__dirname, destinationFile);
16+
17+
// Copy the appropriate file based on the platform
18+
fs.copyFile(sourcePath, destinationPath, (err) => {
19+
if (err) {
20+
console.error(`Error copying file from ${sourcePath} to ${destinationPath}:`, err);
21+
process.exit(1);
22+
}
23+
console.log(`Successfully copied ${sourceFile} to ${destinationFile}`);
24+
});

0 commit comments

Comments
 (0)