Skip to content

Commit f61c5aa

Browse files
Fix hardcoded absolute paths in test.js
- Update test.js to use relative paths with join(__dirname, 'index.js') - Remove hardcoded absolute paths that would break after npm install - Use dynamic path resolution for proper package portability This ensures the test works correctly when the package is installed via npm. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a5a297e commit f61c5aa

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

mcp-package/build.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@ if (existsSync(readmeSrc)) {
7171
const testContent = `#!/usr/bin/env node
7272
7373
import { spawn } from 'child_process';
74+
import { fileURLToPath } from 'url';
75+
import { dirname, join } from 'path';
76+
77+
const __filename = fileURLToPath(import.meta.url);
78+
const __dirname = dirname(__filename);
7479
7580
console.log('Testing @drupaltools/mcp server...');
7681
77-
const server = spawn('node', ['${serverDest}'], {
82+
const server = spawn('node', [join(__dirname, 'index.js')], {
7883
stdio: ['pipe', 'pipe', 'inherit'],
79-
cwd: '${distDir}'
84+
cwd: __dirname
8085
});
8186
8287
let responseCount = 0;

mcp-package/dist/test.js

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

33
import { spawn } from 'child_process';
4+
import { fileURLToPath } from 'url';
5+
import { dirname, join } from 'path';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
49

510
console.log('Testing @drupaltools/mcp server...');
611

7-
const server = spawn('node', ['/var/www/html/NON-DRUPAL/drupaltools.github.io/mcp-package/dist/index.js'], {
12+
const server = spawn('node', [join(__dirname, 'index.js')], {
813
stdio: ['pipe', 'pipe', 'inherit'],
9-
cwd: '/var/www/html/NON-DRUPAL/drupaltools.github.io/mcp-package/dist'
14+
cwd: __dirname
1015
});
1116

1217
let responseCount = 0;

0 commit comments

Comments
 (0)