Skip to content

Commit c51b201

Browse files
francescospissuAkos Kitta
and
Akos Kitta
authored
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 <[email protected]> Co-authored-by: Akos Kitta <[email protected]> Co-authored-by: Akos Kitta <[email protected]>
1 parent 7fed8fe commit c51b201

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

arduino-ide-extension/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"description": "An extension for Theia building the Arduino IDE",
55
"license": "AGPL-3.0-or-later",
66
"scripts": {
7-
"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",
7+
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-i18n && yarn clean && yarn download-examples && yarn build && yarn test",
88
"clean": "rimraf lib",
99
"compose-changelog": "node ./scripts/compose-changelog.js",
1010
"download-cli": "node ./scripts/download-cli.js",
1111
"download-fwuploader": "node ./scripts/download-fwuploader.js",
12-
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
1312
"copy-i18n": "npx ncp ../i18n ./build/i18n",
1413
"download-ls": "node ./scripts/download-ls.js",
1514
"download-examples": "node ./scripts/download-examples.js",
Original file line numberDiff line numberDiff line change
@@ -1,29 +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-
'build',
18-
'arduino-serial-plotter-webapp',
19-
'build',
20-
];
21-
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, '..')));
2215
app.get('/plotter', (req, res) => {
2316
console.log(
2417
`Serving serial plotter on http://${req.headers.host}${req.url}`
2518
);
26-
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
19+
res.sendFile(index);
2720
});
2821
}
2922
}

0 commit comments

Comments
 (0)