未验证 提交 cb65590b 编写于 作者: J Joe Previte

refactor: move tmpdir into src/node/constants

上级 cc99fddf
import { logger } from "@coder/logger"
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
import * as os from "os"
import * as path from "path"
export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJsonFiles {
......@@ -18,3 +19,4 @@ const pkg = getPackageJson("../../package.json")
export const version = pkg.version || "development"
export const commit = pkg.commit || "development"
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 { Emitter } from "../common/emitter"
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
......
......@@ -8,8 +8,6 @@ import * as path from "path"
import * as util from "util"
import xdgBasedir from "xdg-basedir"
export const tmpdir = path.join(os.tmpdir(), "code-server")
interface Paths {
data: string
config: string
......
......@@ -16,23 +16,23 @@ export class CodeServer {
async navigate() {
await this.page.goto(CODE_SERVER_ADDRESS, { waitUntil: "networkidle" })
let editorIsVisible = await this.isEditorVisible()
const editorIsVisible = await this.isEditorVisible()
let reloadCount = 0
// Occassionally code-server timeouts in Firefox
// we're not sure why
// but usually a reload or two fixes it
// 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) {
reloadCount += 1
editorIsVisible = await this.isEditorVisible()
if (editorIsVisible) {
console.log(`Editor became visible after ${reloadCount} reloads`)
if (await this.isEditorVisible()) {
console.log(` Editor became visible after ${reloadCount} reloads`)
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 }) => {
// 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 tmpFile = `${tmpFolderPath}${path.sep}${testFileName}`
// Open terminal and type in value
......
......@@ -4,7 +4,8 @@ import * as net from "net"
import * as os from "os"
import * as path from "path"
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> = {
-readonly [P in keyof T]: T[P]
......
......@@ -4,8 +4,9 @@ import * as net from "net"
import * as path from "path"
import * as tls from "tls"
import { Emitter } from "../../src/common/emitter"
import { tmpdir } from "../../src/node/constants"
import { SocketProxyProvider } from "../../src/node/socket"
import { generateCertificate, tmpdir } from "../../src/node/util"
import { generateCertificate } from "../../src/node/util"
describe("SocketProxyProvider", () => {
const provider = new SocketProxyProvider()
......
import { promises as fs } from "fs"
import * as http from "http"
import * as path from "path"
import { tmpdir } from "../../src/node/constants"
import { SettingsProvider, UpdateSettings } from "../../src/node/settings"
import { LatestResponse, UpdateProvider } from "../../src/node/update"
import { tmpdir } from "../../src/node/util"
describe.skip("update", () => {
let version = "1.0.0"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册