Skip to content

Commit 50762d4

Browse files
committed
Update deno std to 0.132 and enable last tests
1 parent e5b8554 commit 50762d4

File tree

11 files changed

+31
-34
lines changed

11 files changed

+31
-34
lines changed

deno/polyfills.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global Deno */
22

3-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
3+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
44

55
const events = () => ({ data: [], error: [], drain: [], connect: [], secureConnect: [], close: [] })
66

deno/src/bytes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
1+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
22
const size = 256
33
let buffer = Buffer.allocUnsafe(size)
44

deno/src/connection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { HmacSha256 } from 'https://deno.land/std@0.120.0/hash/sha256.ts'
2-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
1+
import { HmacSha256 } from 'https://deno.land/std@0.132.0/hash/sha256.ts'
2+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
33
import { setImmediate, clearImmediate } from '../polyfills.js'
44
import { net } from '../polyfills.js'
55
import { tls } from '../polyfills.js'
6-
import crypto from 'https://deno.land/std@0.120.0/node/crypto.ts'
7-
import Stream from 'https://deno.land/std@0.120.0/node/stream.ts'
6+
import crypto from 'https://deno.land/std@0.132.0/node/crypto.ts'
7+
import Stream from 'https://deno.land/std@0.132.0/node/stream.ts'
88

99
import { Identifier, Builder, handleValue, arrayParser, arraySerializer } from './types.js'
1010
import { Errors } from './errors.js'

deno/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import process from 'https://deno.land/std@0.120.0/node/process.ts'
2-
import os from 'https://deno.land/std@0.120.0/node/os.ts'
3-
import fs from 'https://deno.land/std@0.120.0/node/fs.ts'
1+
import process from 'https://deno.land/std@0.132.0/node/process.ts'
2+
import os from 'https://deno.land/std@0.132.0/node/os.ts'
3+
import fs from 'https://deno.land/std@0.132.0/node/fs.ts'
44

55
import {
66
mergeUserTypes,

deno/src/large.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Stream from 'https://deno.land/std@0.120.0/node/stream.ts'
1+
import Stream from 'https://deno.land/std@0.132.0/node/stream.ts'
22

33
export default function largeObject(sql, oid, mode = 0x00020000 | 0x00040000) {
44
return new Promise(async(resolve, reject) => {

deno/src/subscribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
1+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
22
export default function Subscribe(postgres, options) {
33
const listeners = new Map()
44

deno/src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
1+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
22
import { Query } from './query.js'
33
import { Errors } from './errors.js'
44

deno/tests/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from 'https://deno.land/std@0.120.0/node/child_process.ts'
1+
import { spawn } from 'https://deno.land/std@0.132.0/node/child_process.ts'
22

33
await exec('psql', ['-c', 'alter system set ssl=on'])
44
await exec('psql', ['-c', 'create user postgres_js_test'])

deno/tests/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Buffer } from 'https://deno.land/std@0.120.0/node/buffer.ts'
1+
import { Buffer } from 'https://deno.land/std@0.132.0/node/buffer.ts'
22
/* eslint no-console: 0 */
33

44
import { exec } from './bootstrap.js'
55

66
import { t, nt, ot } from './test.js' // eslint-disable-line
77
import { net } from '../polyfills.js'
8-
import fs from 'https://deno.land/std@0.120.0/node/fs.ts'
9-
import crypto from 'https://deno.land/std@0.120.0/node/crypto.ts'
8+
import fs from 'https://deno.land/std@0.132.0/node/fs.ts'
9+
import crypto from 'https://deno.land/std@0.132.0/node/crypto.ts'
1010

1111
import postgres from '../src/index.js'
1212
const delay = ms => new Promise(r => setTimeout(r, ms))
@@ -1632,7 +1632,7 @@ t('Copy write as first works', async() => {
16321632
]
16331633
})
16341634

1635-
nt('Copy from file works', async() => {
1635+
t('Copy from file works', async() => {
16361636
await sql`create table test (x int, y int, z int)`
16371637
await new Promise(async r => fs
16381638
.createReadStream(rel('copy.csv'))
@@ -1662,7 +1662,7 @@ t('Copy from works in transaction', async() => {
16621662
]
16631663
})
16641664

1665-
nt('Copy from abort works', async() => {
1665+
t('Copy from abort works', async() => {
16661666
const sql = postgres(options)
16671667
const readable = fs.createReadStream(rel('copy.csv'))
16681668

@@ -1827,7 +1827,7 @@ t('Describe a statement without columns', async() => {
18271827
]
18281828
})
18291829

1830-
nt('Large object', async() => {
1830+
t('Large object', async() => {
18311831
const file = rel('index.js')
18321832
, md5 = crypto.createHash('md5').update(fs.readFileSync(file)).digest('hex')
18331833

deno/tests/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import process from 'https://deno.land/std@0.120.0/node/process.ts'
1+
import process from 'https://deno.land/std@0.132.0/node/process.ts'
22
/* eslint no-console: 0 */
33

4-
import util from 'https://deno.land/std@0.120.0/node/util.ts'
4+
import util from 'https://deno.land/std@0.132.0/node/util.ts'
55

66
let done = 0
77
let only = false

transpile.deno.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import fs from 'fs'
22
import path from 'path'
33

4-
const empty = x => fs.readdirSync(x).forEach(f => fs.unlinkSync(path.join(x, f)))
4+
const std = 'https://deno.land/std@0.132.0/'
5+
, empty = x => fs.readdirSync(x).forEach(f => fs.unlinkSync(path.join(x, f)))
56
, ensureEmpty = x => !fs.existsSync(x) ? fs.mkdirSync(x) : empty(x)
67
, root = 'deno'
78
, src = path.join(root, 'src')
@@ -49,33 +50,29 @@ function transpile(x, name, folder) {
4950
.replace(/\nexec\(/g, '\nawait exec(')
5051
.replace('{ spawnSync }', '{ spawn }')
5152
}
52-
53-
if (name === 'index.js') {
54-
// Ignore tests that use node create stream functions not supported in deno yet
55-
x = x.replace(/(t\('Copy from file works)/, 'n$1')
56-
.replace(/(t\('Copy from abort works)/, 'n$1')
57-
.replace(/(t\('Large object)/, 'n$1')
58-
}
5953
}
6054

6155
const buffer = x.includes('Buffer')
62-
? 'import { Buffer } from \'https://deno.land/std@0.120.0/node/buffer.ts\'\n'
56+
? 'import { Buffer } from \'' + std + 'node/buffer.ts\'\n'
6357
: ''
6458

6559
const process = x.includes('process.')
66-
? 'import process from \'https://deno.land/std@0.120.0/node/process.ts\'\n'
60+
? 'import process from \'' + std + 'node/process.ts\'\n'
6761
: ''
6862

6963
const timers = x.includes('setImmediate')
7064
? 'import { setImmediate, clearImmediate } from \'../polyfills.js\'\n'
7165
: ''
7266

7367
const hmac = x.includes('createHmac')
74-
? 'import { HmacSha256 } from \'https://deno.land/std@0.120.0/hash/sha256.ts\'\n'
68+
? 'import { HmacSha256 } from \'' + std + 'hash/sha256.ts\'\n'
7569
: ''
7670

7771
return hmac + buffer + process + timers + x
78-
.replace(/setTimeout\((.*)\)\.unref\(\)/g, '(window.timer = setTimeout($1), Deno.unrefTimer(window.timer), window.timer)')
72+
.replace(
73+
/setTimeout\((.*)\)\.unref\(\)/g,
74+
'(window.timer = setTimeout($1), Deno.unrefTimer(window.timer), window.timer)'
75+
)
7976
.replace(
8077
'crypto.createHmac(\'sha256\', key).update(x).digest()',
8178
'Buffer.from(new HmacSha256(key).update(x).digest())'
@@ -87,5 +84,5 @@ function transpile(x, name, folder) {
8784
.replace(/.setKeepAlive\([^)]+\)/g, '')
8885
.replace(/import net from 'net'/, 'import { net } from \'../polyfills.js\'')
8986
.replace(/import tls from 'tls'/, 'import { tls } from \'../polyfills.js\'')
90-
.replace(/ from '([a-z_]+)'/g, ' from \'https://deno.land/std@0.120.0/node/$1.ts\'')
87+
.replace(/ from '([a-z_]+)'/g, ' from \'' + std + 'node/$1.ts\'')
9188
}

0 commit comments

Comments
 (0)