mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-03 06:07:41 +00:00
fix(developer): use path not dependent on pwd for starting Server
Fixes: #12165 Test-bot: skip
This commit is contained in:
parent
f8a5164c57
commit
f65299cb36
2 changed files with 27 additions and 1 deletions
|
|
@ -1,5 +1,25 @@
|
|||
/*
|
||||
* Keyman is copyright (C) SIL Global. MIT License.
|
||||
*
|
||||
* Environmental variables and paths
|
||||
*/
|
||||
import path from 'node:path';
|
||||
import { extractVersionData } from './version-data.js';
|
||||
// TODO: environment should be just KEYMAN_VERSION
|
||||
|
||||
import KEYMAN_VERSION from "@keymanapp/keyman-version";
|
||||
export const environment = extractVersionData(KEYMAN_VERSION.VERSION_WITH_TAG);
|
||||
|
||||
/**
|
||||
* @returns base path for the running server -- where index.js is stored
|
||||
*/
|
||||
export function serverBasePath() {
|
||||
return path.join(import.meta.dirname, '../../build/src');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns path where the site public files can be found -- index.html
|
||||
*/
|
||||
export function serverSitePath() {
|
||||
return path.join(serverBasePath(), 'site');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* Keyman is copyright (C) SIL Global. MIT License.
|
||||
*
|
||||
* Setup URL routes for Keyman Developer Server
|
||||
*/
|
||||
import * as express from 'express';
|
||||
import * as ws from 'ws';
|
||||
import * as multer from 'multer';
|
||||
|
|
@ -16,6 +21,7 @@ import { standardPaths } from './standardPaths.js';
|
|||
import chalk from 'chalk';
|
||||
import { shutdown } from './shutdown.js';
|
||||
import { getOption } from './options.js';
|
||||
import { serverSitePath } from './environment.js';
|
||||
|
||||
export default function setupRoutes(app: express.Express, upload: multer.Multer, wsServer: ws.WebSocketServer, environment: Environment ) {
|
||||
|
||||
|
|
@ -51,7 +57,7 @@ export default function setupRoutes(app: express.Express, upload: multer.Multer,
|
|||
|
||||
/* All routes */
|
||||
|
||||
app.use('/', express.static('build/src/site'));
|
||||
app.use('/', express.static(serverSitePath()));
|
||||
|
||||
app.post('/upload', localhostOnly, upload.single('file'), (req, res, next) => {
|
||||
const name = req.file.originalname;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue