mirror of https://git.tuxpa.in/a/code-server.git
refactor: move tmpdir into src/node/constants
This commit is contained in:
parent
cc99fddf24
commit
cb65590b98
|
@ -1,5 +1,6 @@
|
||||||
import { logger } from "@coder/logger"
|
import { logger } from "@coder/logger"
|
||||||
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
|
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
|
||||||
|
import * as os from "os"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
|
|
||||||
export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJsonFiles {
|
export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJsonFiles {
|
||||||
|
@ -18,3 +19,4 @@ const pkg = getPackageJson("../../package.json")
|
||||||
export const version = pkg.version || "development"
|
export const version = pkg.version || "development"
|
||||||
export const commit = pkg.commit || "development"
|
export const commit = pkg.commit || "development"
|
||||||
export const rootPath = path.resolve(__dirname, "../..")
|
export const rootPath = path.resolve(__dirname, "../..")
|
||||||
|
export const tmpdir = path.join(os.tmpdir(), "code-server")
|
||||||
|
|
|
@ -4,7 +4,8 @@ import * as path from "path"
|
||||||
import * as tls from "tls"
|
import * as tls from "tls"
|
||||||
import { Emitter } from "../common/emitter"
|
import { Emitter } from "../common/emitter"
|
||||||
import { generateUuid } from "../common/util"
|
import { generateUuid } from "../common/util"
|
||||||
import { canConnect, tmpdir } from "./util"
|
import { tmpdir } from "./constants"
|
||||||
|
import { canConnect } from "./util"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a way to proxy a TLS socket. Can be used when you need to pass a
|
* Provides a way to proxy a TLS socket. Can be used when you need to pass a
|
||||||
|
|
|
@ -8,8 +8,6 @@ import * as path from "path"
|
||||||
import * as util from "util"
|
import * as util from "util"
|
||||||
import xdgBasedir from "xdg-basedir"
|
import xdgBasedir from "xdg-basedir"
|
||||||
|
|
||||||
export const tmpdir = path.join(os.tmpdir(), "code-server")
|
|
||||||
|
|
||||||
interface Paths {
|
interface Paths {
|
||||||
data: string
|
data: string
|
||||||
config: string
|
config: string
|
||||||
|
|
|
@ -16,23 +16,23 @@ export class CodeServer {
|
||||||
async navigate() {
|
async navigate() {
|
||||||
await this.page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
await this.page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
|
||||||
|
|
||||||
let editorIsVisible = await this.isEditorVisible()
|
const editorIsVisible = await this.isEditorVisible()
|
||||||
let reloadCount = 0
|
let reloadCount = 0
|
||||||
|
|
||||||
// Occassionally code-server timeouts in Firefox
|
// Occassionally code-server timeouts in Firefox
|
||||||
// we're not sure why
|
// we're not sure why
|
||||||
// but usually a reload or two fixes it
|
// but usually a reload or two fixes it
|
||||||
// TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues
|
// TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues
|
||||||
// TODO@jsjoeio sometimes it's 2 reloads, othertimes it's 9
|
|
||||||
// double-check this logic
|
|
||||||
while (!editorIsVisible) {
|
while (!editorIsVisible) {
|
||||||
reloadCount += 1
|
reloadCount += 1
|
||||||
editorIsVisible = await this.isEditorVisible()
|
if (await this.isEditorVisible()) {
|
||||||
if (editorIsVisible) {
|
console.log(` Editor became visible after ${reloadCount} reloads`)
|
||||||
console.log(`Editor became visible after ${reloadCount} reloads`)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
await this.page.reload({ waitUntil: "networkidle" })
|
// When a reload happens, we want to wait for all resources to be
|
||||||
|
// loaded completely. Hence why we use that instead of DOMContentLoaded
|
||||||
|
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/
|
||||||
|
await this.page.reload({ waitUntil: "load" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,10 @@ test.describe("Integrated Terminal", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test("should echo a string to a file", options, async ({ page }) => {
|
test("should echo a string to a file", options, async ({ page }) => {
|
||||||
|
// NOTE@jsjoeio
|
||||||
|
// We're not using tmpdir from src/node/constants
|
||||||
|
// because Playwright doesn't fully support ES modules from
|
||||||
|
// the erorrs I'm seeing
|
||||||
const tmpFolderPath = fs.mkdtempSync(path.join(tmpdir(), "code-server-test"))
|
const tmpFolderPath = fs.mkdtempSync(path.join(tmpdir(), "code-server-test"))
|
||||||
const tmpFile = `${tmpFolderPath}${path.sep}${testFileName}`
|
const tmpFile = `${tmpFolderPath}${path.sep}${testFileName}`
|
||||||
// Open terminal and type in value
|
// Open terminal and type in value
|
||||||
|
|
|
@ -4,7 +4,8 @@ import * as net from "net"
|
||||||
import * as os from "os"
|
import * as os from "os"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { Args, parse, setDefaults, shouldOpenInExistingInstance } from "../../src/node/cli"
|
import { Args, parse, setDefaults, shouldOpenInExistingInstance } from "../../src/node/cli"
|
||||||
import { paths, tmpdir } from "../../src/node/util"
|
import { tmpdir } from "../../src/node/constants"
|
||||||
|
import { paths } from "../../src/node/util"
|
||||||
|
|
||||||
type Mutable<T> = {
|
type Mutable<T> = {
|
||||||
-readonly [P in keyof T]: T[P]
|
-readonly [P in keyof T]: T[P]
|
||||||
|
|
|
@ -4,8 +4,9 @@ import * as net from "net"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import * as tls from "tls"
|
import * as tls from "tls"
|
||||||
import { Emitter } from "../../src/common/emitter"
|
import { Emitter } from "../../src/common/emitter"
|
||||||
|
import { tmpdir } from "../../src/node/constants"
|
||||||
import { SocketProxyProvider } from "../../src/node/socket"
|
import { SocketProxyProvider } from "../../src/node/socket"
|
||||||
import { generateCertificate, tmpdir } from "../../src/node/util"
|
import { generateCertificate } from "../../src/node/util"
|
||||||
|
|
||||||
describe("SocketProxyProvider", () => {
|
describe("SocketProxyProvider", () => {
|
||||||
const provider = new SocketProxyProvider()
|
const provider = new SocketProxyProvider()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { promises as fs } from "fs"
|
import { promises as fs } from "fs"
|
||||||
import * as http from "http"
|
import * as http from "http"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
|
import { tmpdir } from "../../src/node/constants"
|
||||||
import { SettingsProvider, UpdateSettings } from "../../src/node/settings"
|
import { SettingsProvider, UpdateSettings } from "../../src/node/settings"
|
||||||
import { LatestResponse, UpdateProvider } from "../../src/node/update"
|
import { LatestResponse, UpdateProvider } from "../../src/node/update"
|
||||||
import { tmpdir } from "../../src/node/util"
|
|
||||||
|
|
||||||
describe.skip("update", () => {
|
describe.skip("update", () => {
|
||||||
let version = "1.0.0"
|
let version = "1.0.0"
|
||||||
|
|
Loading…
Reference in New Issue