Skip to content

Commit afd8bf8

Browse files
francescospissuAkos Kitta
and
Akos Kitta
authored
Use require#resolve to locate the plotter app. (#1178)
Signed-off-by: Akos Kitta <[email protected]> Co-authored-by: Akos Kitta <[email protected]>
1 parent f9bf009 commit afd8bf8

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1+
import * as path from 'path';
12
import * as express from 'express';
23
import { injectable } from '@theia/core/shared/inversify';
34
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
4-
import path = require('path');
55

66
@injectable()
77
export class PlotterBackendContribution
88
implements BackendApplicationContribution
99
{
10-
async initialize(): Promise<void> {}
11-
1210
configure(app: express.Application): void {
13-
const relativePath = [
14-
'..',
15-
'..',
16-
'..',
17-
'..',
18-
'node_modules',
19-
'arduino-serial-plotter-webapp',
20-
'build',
21-
];
22-
app.use(express.static(path.join(__dirname, ...relativePath)));
11+
const index = require.resolve(
12+
'arduino-serial-plotter-webapp/build/index.html'
13+
);
14+
app.use(express.static(path.join(index, '..')));
2315
app.get('/plotter', (req, res) => {
2416
console.log(
2517
`Serving serial plotter on http://${req.headers.host}${req.url}`
2618
);
27-
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
19+
res.sendFile(index);
2820
});
2921
}
3022
}

0 commit comments

Comments
 (0)