mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-13 20:29:27 +00:00
Avoid twice serial plotter apps (#1174)
* avoid twice serial plotter apps * remove copy-serial-plotter script. * Use `require#resolve` to locate the plotter app. (#1178) Signed-off-by: Akos Kitta <a.kitta@arduino.cc> Co-authored-by: Akos Kitta <a.kitta@arduino.cc> Co-authored-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
import * as path from 'path';
|
||||
import * as express from 'express';
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
|
||||
import path = require('path');
|
||||
|
||||
@injectable()
|
||||
export class PlotterBackendContribution
|
||||
implements BackendApplicationContribution
|
||||
{
|
||||
async initialize(): Promise<void> {}
|
||||
|
||||
configure(app: express.Application): void {
|
||||
const relativePath = [
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'build',
|
||||
'arduino-serial-plotter-webapp',
|
||||
'build',
|
||||
];
|
||||
app.use(express.static(path.join(__dirname, ...relativePath)));
|
||||
const index = require.resolve(
|
||||
'arduino-serial-plotter-webapp/build/index.html'
|
||||
);
|
||||
app.use(express.static(path.join(index, '..')));
|
||||
app.get('/plotter', (req, res) => {
|
||||
console.log(
|
||||
`Serving serial plotter on http://${req.headers.host}${req.url}`
|
||||
);
|
||||
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
|
||||
res.sendFile(index);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user