Skip to content

Commit 3de3613

Browse files
committed
Resolve paths
Fixes #19.
1 parent 57acda8 commit 3de3613

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/server/src/cli.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ export class Entry extends Command {
4949
}
5050

5151
const { args, flags } = this.parse(Entry);
52-
const dataDir = flags["data-dir"] || path.join(os.homedir(), ".code-server");
53-
const workingDir = args["workdir"];
52+
const dataDir = path.resolve(flags["data-dir"] || path.join(os.homedir(), ".code-server"));
53+
const workingDir = path.resolve(args["workdir"]);
5454

5555
setupNativeModules(dataDir);
56-
const builtInExtensionsDir = path.join(buildDir || path.join(__dirname, ".."), "build/extensions");
56+
const builtInExtensionsDir = path.resolve(buildDir || path.join(__dirname, ".."), "build/extensions");
5757
if (flags["bootstrap-fork"]) {
5858
const modulePath = flags["bootstrap-fork"];
5959
if (!modulePath) {
@@ -84,8 +84,8 @@ export class Entry extends Command {
8484
const logDir = path.join(dataDir, "logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
8585
process.env.VSCODE_LOGS = logDir;
8686

87-
const certPath = flags.cert;
88-
const certKeyPath = flags["cert-key"];
87+
const certPath = flags.cert ? path.resolve(flags.cert) : undefined;
88+
const certKeyPath = flags["cert-key"] ? path.resolve(flags["cert-key"]) : undefined;
8989

9090
if (certPath && !certKeyPath) {
9191
logger.error("'--cert-key' flag is required when specifying a certificate!");
@@ -135,9 +135,9 @@ export class Entry extends Command {
135135
}
136136
});
137137

138-
let password = flags["password"];
138+
let password = flags.password;
139139
if (!password) {
140-
// Generate a random password
140+
// Generate a random password with a length of 24.
141141
const buffer = Buffer.alloc(12);
142142
randomFillSync(buffer);
143143
password = buffer.toString("hex");
@@ -158,7 +158,7 @@ export class Entry extends Command {
158158
// If we're not running from the binary and we aren't serving the static
159159
// pre-built version, use webpack to serve the web files.
160160
if (!isCli && !serveStatic) {
161-
const webpackConfig = require(path.join(__dirname, "..", "..", "web", "webpack.config.js"));
161+
const webpackConfig = require(path.resolve(__dirname, "..", "..", "web", "webpack.config.js"));
162162
const compiler = require("webpack")(webpackConfig);
163163
app.use(require("webpack-dev-middleware")(compiler, {
164164
logger,

packages/server/src/constants.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as path from "path";
2+
13
export const isCli = typeof process.env.CLI !== "undefined" && process.env.CLI !== "false";
24
export const serveStatic = typeof process.env.SERVE_STATIC !== "undefined" && process.env.SERVE_STATIC !== "false";
3-
export const buildDir = process.env.BUILD_DIR;
5+
export const buildDir = process.env.BUILD_DIR ? path.resolve(process.env.BUILD_DIR) : "";

0 commit comments

Comments
 (0)