Skip to content

Commit aa8dac6

Browse files
committed
chore: use Promise.resolve for better compatibility
the plv8 entrypoint shims the global Promise object, so no need to call it explicitly.
1 parent 7a1e9e6 commit aa8dac6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/git.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as memfs from 'memfs'
22
import * as path from 'path'
33
import * as git from 'isomorphic-git'
44
import * as serializer from './serializer'
5-
import {SyncPromise} from './sync-promise'
65
import {PG_Vars} from './pg-types'
76
import {setupMemfs} from './fs'
87

@@ -31,7 +30,7 @@ export const rowToRepo = ({OLD, NEW, ...pg}: PG_Vars) => {
3130

3231
const commitMessage = `${pg.TG_NAME}: ${pg.TG_WHEN} ${pg.TG_OP} ${pg.TG_LEVEL} on ${pg.TG_TABLE_SCHEMA}.${pg.TG_TABLE_NAME}`.trim()
3332

34-
return SyncPromise.resolve()
33+
return Promise.resolve()
3534
.then(setupGitFolder)
3635
.then(() => {
3736
if (!NEW) return
@@ -42,7 +41,7 @@ export const rowToRepo = ({OLD, NEW, ...pg}: PG_Vars) => {
4241
const filepath = `${repo.dir}/${k}`
4342
fs.writeFileSync(filepath, content, {encoding: 'utf8'})
4443
})
45-
return SyncPromise.resolve()
44+
return Promise.resolve()
4645
.then(() => git.add({...repo, filepath: '.'}))
4746
.then(() =>
4847
git.commit({
@@ -52,7 +51,7 @@ export const rowToRepo = ({OLD, NEW, ...pg}: PG_Vars) => {
5251
}),
5352
)
5453
.then(commit =>
55-
SyncPromise.all(
54+
Promise.all(
5655
(NEW?.git?.tags || []).map((tag: string) => {
5756
return git.tag({...repo, ref: tag, object: commit})
5857
}),
@@ -88,19 +87,19 @@ export const gitLog = (gitRepoJson: object, depth?: number) => {
8887
const {fs} = setupMemfs()
8988
const repo = {fs, dir: '/repo'}
9089

91-
return SyncPromise.resolve()
90+
return Promise.resolve()
9291
.then(() => writeGitFiles(gitRepoJson, fs))
9392
.then(() => git.log({...repo, depth}))
9493
.then(log => {
95-
return SyncPromise.all(
94+
return Promise.all(
9695
log.map(e => {
9796
return git
9897
.walk({
9998
...repo,
10099
trees: [e.oid, e.commit.parent[0]].filter(Boolean).map(ref => git.TREE({ref})),
101100
map: (filepath, entries) => {
102101
const [Child, Parent] = entries || []
103-
return SyncPromise.all([resolveTree(Child), Parent && resolveTree(Parent)]).then(
102+
return Promise.all([resolveTree(Child), Parent && resolveTree(Parent)]).then(
104103
([ChildInfo, ParentInfo]): WalkResult => ({filepath, ChildInfo, ParentInfo} as WalkResult),
105104
)
106105
},
@@ -134,7 +133,7 @@ export const gitResolve = (gitRepoJson: object, ref: string) => {
134133
const {fs} = setupMemfs()
135134
const repo = {fs, dir: '/repo'}
136135

137-
return SyncPromise.resolve()
136+
return Promise.resolve()
138137
.then(() => writeGitFiles(gitRepoJson, fs))
139138
.then(() =>
140139
git.walk({
@@ -164,5 +163,5 @@ type ResolvedTree = PromiseResult<ReturnType<typeof resolveTree>>
164163
/** gets the type, content and oid for a `WalkerEntry` */
165164
const resolveTree = (tree: git.WalkerEntry | undefined) => {
166165
const promises = tree && [tree.type(), tree.content().then(btos), tree.oid()]
167-
return promises && SyncPromise.all(promises).then(([type, content, oid]) => ({type, content, oid}))
166+
return promises && Promise.all(promises).then(([type, content, oid]) => ({type, content, oid}))
168167
}

0 commit comments

Comments
 (0)