Skip to content

Commit 4afd61c

Browse files
committed
Replace usage of express
1 parent 1a86c1e commit 4afd61c

3 files changed

Lines changed: 48 additions & 332 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"eslint": "6.8.0",
9898
"eslint-plugin-jsdoc": "^19.1.0",
9999
"event-stream": "3.3.4",
100-
"express": "^4.13.1",
101100
"fancy-log": "^1.3.3",
102101
"fast-plist": "0.1.2",
103102
"glob": "^5.0.13",
@@ -157,7 +156,8 @@
157156
"vscode-nls-dev": "^3.3.1",
158157
"webpack": "^4.16.5",
159158
"webpack-cli": "^3.3.8",
160-
"webpack-stream": "^5.1.1"
159+
"webpack-stream": "^5.1.1",
160+
"yaserver": "^0.2.0"
161161
},
162162
"repository": {
163163
"type": "git",

test/browser.js

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
const express = require('express');
6+
const yaserver = require('yaserver');
7+
const http = require('http');
78
const glob = require('glob');
89
const path = require('path');
910
const fs = require('fs');
@@ -17,32 +18,32 @@ function template(str, env) {
1718
});
1819
}
1920

20-
var app = express();
21-
22-
app.use('/out', express.static(path.join(REPO_ROOT, 'out')));
23-
app.use('/test', express.static(path.join(REPO_ROOT, 'test')));
24-
app.use('/node_modules', express.static(path.join(REPO_ROOT, 'node_modules')));
25-
26-
app.get('/', function (req, res) {
27-
glob('**/vs/{base,platform,editor}/**/test/{common,browser}/**/*.test.js', {
28-
cwd: path.join(REPO_ROOT, 'out'),
29-
// ignore: ['**/test/{node,electron*}/**/*.js']
30-
}, function (err, files) {
31-
if (err) { return res.sendStatus(500); }
32-
33-
var modules = files
34-
.map(function (file) { return file.replace(/\.js$/, ''); });
35-
36-
fs.readFile(path.join(__dirname, 'index.html'), 'utf8', function (err, templateString) {
37-
if (err) { return res.sendStatus(500); }
38-
39-
res.send(template(templateString, {
40-
modules: JSON.stringify(modules)
41-
}));
42-
});
21+
yaserver.createServer({ rootDir: REPO_ROOT }).then((staticServer) => {
22+
const server = http.createServer((req, res) => {
23+
if (req.url === '' || req.url === '/') {
24+
glob('**/vs/{base,platform,editor}/**/test/{common,browser}/**/*.test.js', {
25+
cwd: path.join(REPO_ROOT, 'out'),
26+
// ignore: ['**/test/{node,electron*}/**/*.js']
27+
}, function (err, files) {
28+
if (err) { return res.sendStatus(500); }
29+
30+
var modules = files
31+
.map(function (file) { return file.replace(/\.js$/, ''); });
32+
33+
fs.readFile(path.join(__dirname, 'index.html'), 'utf8', function (err, templateString) {
34+
if (err) { return res.sendStatus(500); }
35+
36+
res.end(template(templateString, {
37+
modules: JSON.stringify(modules)
38+
}));
39+
});
40+
});
41+
} else {
42+
return staticServer.handle(req, res);
43+
}
4344
});
44-
});
4545

46-
app.listen(PORT, function () {
47-
console.log('http://localhost:8887/');
46+
server.listen(PORT, () => {
47+
console.log(`http://localhost:${PORT}/`);
48+
});
4849
});

0 commit comments

Comments
 (0)