Skip to content

Commit

Permalink
fix(globals): import utils in test. fix build editor globals
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlindquist committed Dec 4, 2024
1 parent e07dc72 commit 2b4d87d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
22 changes: 11 additions & 11 deletions build/build-editor-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ for (let def of kitDefs) {
kitContent += await readFile(path.resolve("src", "types", def), "utf8")
}

let globalDefs = path.resolve(
"node_modules",
"@johnlindquist",
"globals",
"types"
)
// let globalDefs = path.resolve(
// "node_modules",
// "@johnlindquist",
// "globals",
// "types"
// )

let globalTypeDirs = (await readdir(globalDefs)).filter(
(dir) => !dir.endsWith(".ts")
)
// let globalTypeDirs = (await readdir(globalDefs)).filter(
// (dir) => !dir.endsWith(".ts")
// )

console.log({ defs: kitDefs, globalTypeDirs })
// console.log({ defs: kitDefs, globalTypeDirs })

// GlobalsAPI
kitContent += await readFile(path.resolve(globalDefs, "index.d.ts"), "utf8")
// kitContent += await readFile(path.resolve(globalDefs, "index.d.ts"), "utf8")

// content = `declare module '@johnlindquist/kit' {

Expand Down
1 change: 1 addition & 0 deletions src/api/global.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ava.serial("env should work with different params", async (t) => {
ava.serial("All globals exist", async (t) => {
// TODO: Make platform independent...
/** @type {import("../platform/darwin")} */
await import(pathToFileURL(kitPath("core", "utils.js")).href)
await import(pathToFileURL(kitPath("platform", "darwin.js")).href)
await import(pathToFileURL(kitPath("target", "app.js")).href)
await import(pathToFileURL(kitPath("api", "pro.js")).href)
Expand Down
2 changes: 2 additions & 0 deletions src/api/packages/shelljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
tempdir,
test,
which,
cd,
} = shelljs

global.cp = cp
Expand All @@ -35,5 +36,6 @@ global.tempdir = tempdir
global.test = test
global.which = which
global.pwd = pwd
global.cd = cd

export {}
1 change: 1 addition & 0 deletions src/globals/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export let writeFileSync = (global.writeFileSync = fs.writeFileSync)
export let appendFileSync = (global.appendFileSync = fs.appendFileSync)
export let readdirSync = (global.readdirSync = fs.readdirSync)
export let copyFileSync = (global.copyFileSync = fs.copyFileSync)
export let renameSync = (global.renameSync = fs.renameSync)


export let createReadStream = (global.createReadStream = fs.createReadStream)
Expand Down
6 changes: 2 additions & 4 deletions src/types/packages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ export type OnTab = (name: string, fn: () => void) => void

export type TmpPromise = typeof import("tmp-promise")

export type Zx = typeof import("zx/build/index")

export interface PackagesApi {
cd: Zx["cd"]
cd: typeof shelljs.cd
cp: typeof shelljs.cp
chmod: typeof shelljs.chmod
echo: typeof shelljs.echo
Expand Down Expand Up @@ -97,7 +95,7 @@ export interface IDegit {
type Degit = (repo: string, options?: DegitOptions) => IDegit

declare global {
var cd: Zx["cd"]
var cd: typeof shelljs.cd
var cp: typeof shelljs.cp
var chmod: typeof shelljs.chmod
var echo: typeof shelljs.echo
Expand Down

0 comments on commit 2b4d87d

Please sign in to comment.