Use ESM in Node.js code generation scripts (#2739)
This commit is contained in:
@@ -87,4 +87,4 @@ cc_test(
|
||||
"tests",
|
||||
"//platform/linux:impl",
|
||||
],
|
||||
)
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
/* jshint node: true */
|
||||
'use strict';
|
||||
import express from "express";
|
||||
import path from "node:path";
|
||||
|
||||
if (!import.meta.dirname) throw new Error("Could not get import.meta.dirname. Use Node.js 20.11 or newer.");
|
||||
|
||||
// This needs to be here to make sure the pipe stays open.
|
||||
// We're waiting until the stdin pipe gets closed (e.g. because the parent
|
||||
@@ -8,9 +9,6 @@
|
||||
process.stdin.on('readable', function() {});
|
||||
process.stdin.on('end', function() { process.exit(0); });
|
||||
|
||||
|
||||
var fs = require('fs');
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
// We're manually setting Etag headers.
|
||||
@@ -170,7 +168,7 @@ app.get('/load/:number(\\d+)', function(req, res) {
|
||||
});
|
||||
|
||||
app.get('/online/:style(*)', function(req, res) {
|
||||
const file = (__dirname + "/../fixtures/map/online/" + req.params.style).replace("storage/../", "");
|
||||
const file = path.join(import.meta.dirname, "../fixtures/map/online", req.params.style);
|
||||
res.sendFile(file); // Set disposition and send it.
|
||||
// res.status(200).send();
|
||||
// res.send('Request ' + req.params.style);
|
||||
|
||||
Reference in New Issue
Block a user