Skip to content

Commit

Permalink
fix: use mycloud compatible typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheidegger committed Apr 26, 2022
1 parent d525d39 commit 5fab4f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { SpawnOptions } from 'child_process'
import { spawn } from 'child_process'
import { spawn, SpawnOptions } from 'child_process'
import { mkdir, readFile, writeFile, stat, utimes } from 'fs/promises'
import dbg from 'debug'
import * as path from 'path'
Expand Down Expand Up @@ -247,8 +246,8 @@ export class Plugin {
readonly name: string
readonly path: string

#data: Promise<any> | undefined
#pkg: Promise<any> | undefined
_data: Promise<any> | undefined
_pkg: Promise<any> | undefined

constructor (name: string, path: string) {
this.name = name
Expand All @@ -257,21 +256,21 @@ export class Plugin {

/* eslint-disable-next-line @typescript-eslint/promise-function-async */
package ({ force }: { force?: boolean } = {}): Promise<any> {
let pkg = this.#pkg
let pkg = this._pkg
if (pkg === undefined || force !== true) {
pkg = loadPackage(this.name, this.path)
this.#pkg = pkg
this._pkg = pkg
}
return pkg
}

/* eslint-disable-next-line @typescript-eslint/promise-function-async */
data (opts?: { force?: boolean }): Promise<any> {
let data = this.#data
let data = this._data
if (data === undefined || opts?.force !== true) {
/* eslint-disable-next-line @typescript-eslint/promise-function-async */
data = this.package(opts).then(pkg => loadData(this.name, this.path, pkg))
this.#data = data
this._data = data
}
return data
}
Expand All @@ -289,8 +288,8 @@ async function prepare ({ tmpDir, names }: { tmpDir: string, names: string[] }):
}

export async function loadPlugins (plugins: FNOrResult<PluginDefinitions>, { tmpDir, maxAge }: { tmpDir?: string, maxAge?: number } = {}): Promise<{ [key: string]: Plugin }> {
tmpDir ??= DEFAULT_TMP_DIR
maxAge ??= DEFAULT_MAX_AGE
tmpDir = tmpDir ?? DEFAULT_TMP_DIR
maxAge = maxAge ?? DEFAULT_MAX_AGE
const names = await assertInstalled(plugins, { tmpDir, maxAge })
return await prepare({ tmpDir, names })
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/node": "^17.0.16",
"aws-sdk": "^2.1001.0",
"c8": "^7.11.0",
"fresh-tape": "^5.5.3",
"ts-node": "^10.5.0",
"ts-standard": "^11.0.0",
"typescript": "^4.4.4",
"aws-sdk": "^2.1001.0"
"typescript": "^3.7.7"
},
"dependencies": {
"debug": "^4.3.3",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.mjs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2020",
"module": "esnext",
"outDir": "mjs"
}
}

0 comments on commit 5fab4f4

Please sign in to comment.