mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-15 15:26:32 +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:
parent
7fed8febf1
commit
c51b201362
@ -4,12 +4,11 @@
|
|||||||
"description": "An extension for Theia building the Arduino IDE",
|
"description": "An extension for Theia building the Arduino IDE",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
|
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
|
||||||
"clean": "rimraf lib",
|
"clean": "rimraf lib",
|
||||||
"compose-changelog": "node ./scripts/compose-changelog.js",
|
"compose-changelog": "node ./scripts/compose-changelog.js",
|
||||||
"download-cli": "node ./scripts/download-cli.js",
|
"download-cli": "node ./scripts/download-cli.js",
|
||||||
"download-fwuploader": "node ./scripts/download-fwuploader.js",
|
"download-fwuploader": "node ./scripts/download-fwuploader.js",
|
||||||
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
|
|
||||||
"copy-i18n": "npx ncp ../i18n ./build/i18n",
|
"copy-i18n": "npx ncp ../i18n ./build/i18n",
|
||||||
"download-ls": "node ./scripts/download-ls.js",
|
"download-ls": "node ./scripts/download-ls.js",
|
||||||
"download-examples": "node ./scripts/download-examples.js",
|
"download-examples": "node ./scripts/download-examples.js",
|
||||||
|
@ -1,29 +1,22 @@
|
|||||||
|
import * as path from 'path';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import { injectable } from '@theia/core/shared/inversify';
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
|
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
|
||||||
import path = require('path');
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class PlotterBackendContribution
|
export class PlotterBackendContribution
|
||||||
implements BackendApplicationContribution
|
implements BackendApplicationContribution
|
||||||
{
|
{
|
||||||
async initialize(): Promise<void> {}
|
|
||||||
|
|
||||||
configure(app: express.Application): void {
|
configure(app: express.Application): void {
|
||||||
const relativePath = [
|
const index = require.resolve(
|
||||||
'..',
|
'arduino-serial-plotter-webapp/build/index.html'
|
||||||
'..',
|
);
|
||||||
'..',
|
app.use(express.static(path.join(index, '..')));
|
||||||
'build',
|
|
||||||
'arduino-serial-plotter-webapp',
|
|
||||||
'build',
|
|
||||||
];
|
|
||||||
app.use(express.static(path.join(__dirname, ...relativePath)));
|
|
||||||
app.get('/plotter', (req, res) => {
|
app.get('/plotter', (req, res) => {
|
||||||
console.log(
|
console.log(
|
||||||
`Serving serial plotter on http://${req.headers.host}${req.url}`
|
`Serving serial plotter on http://${req.headers.host}${req.url}`
|
||||||
);
|
);
|
||||||
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
|
res.sendFile(index);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user