Skip to content

Commit cd57d75

Browse files
authored
Merge pull request #58 from balena-io-modules/5.x
5.x
2 parents 1c04b5c + e715af4 commit cd57d75

8 files changed

Lines changed: 42 additions & 32 deletions

File tree

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Set all files to use line feed endings (since we can't match only ones without an extension)
2+
* eol=lf
3+
# And then reset all the files with extensions back to default
4+
*.* -eol
5+
6+
*.sh text eol=lf

lib/btrfs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from './utils';
1+
import { spawn } from './utils.js';
22

33
export const deleteSubvolAsync = function (subvol: string) {
44
return spawn('btrfs', ['subvolume', 'delete', subvol]).waitAsync();

lib/docker-delta.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import path from 'node:path';
2-
import Bluebird from 'bluebird';
32
import stream from 'node:stream';
43
import { TypedError } from 'typed-error';
5-
import * as rsync from './rsync';
6-
import * as btrfs from './btrfs';
7-
import { spawn } from './utils';
4+
import * as rsync from './rsync.js';
5+
import * as btrfs from './btrfs.js';
6+
import { spawn } from './utils.js';
87
import type Dockerode from 'dockerode';
98
import * as dt from 'docker-toolbelt';
9+
import pTimeout from 'p-timeout';
1010

1111
const DELTA_OUT_OF_SYNC_CODES = [19, 23, 24];
1212

@@ -139,16 +139,16 @@ async function applyBatch(
139139
let p = stream.promises.pipeline(batch, rsyncProcess.stdin!);
140140

141141
if (timeout !== 0) {
142-
p = Bluebird.resolve(p).timeout(timeout);
142+
p = pTimeout(p, { milliseconds: timeout });
143143
}
144144

145145
try {
146146
await p;
147147
log('Batch input stream ended; waiting for rsync...');
148148
try {
149-
await Bluebird.resolve(rsyncProcess.waitAsync()).timeout(
150-
RSYNC_EXIT_TIMEOUT,
151-
);
149+
await pTimeout(rsyncProcess.waitAsync(), {
150+
milliseconds: RSYNC_EXIT_TIMEOUT,
151+
});
152152
log('rsync exited cleanly');
153153
} catch (err) {
154154
log(`Error waiting for rsync to exit: ${err}`);

lib/rsync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import tmp from 'tmp-promise';
33
import path from 'node:path';
4-
import { spawn, mkfifoSync } from './utils';
4+
import { spawn, mkfifoSync } from './utils.js';
55

66
export const createRsyncStream = async function (
77
src: string,

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "docker-delta",
33
"version": "4.1.1",
44
"description": "Generate binary filesystem diffs between docker images to speed up distribution",
5-
"main": "out/docker-delta",
5+
"type": "module",
6+
"main": "out/docker-delta.js",
7+
"engines": {
8+
"node": ">=22.22.0 <23.0.0 || >=24.13.0"
9+
},
610
"scripts": {
711
"lint-fix": "balena-lint -t tsconfig.dev.json --fix -e js -e ts lib/ test/",
812
"lint": "balena-lint -t tsconfig.dev.json -e js -e ts lib/ test/",
@@ -12,23 +16,22 @@
1216
"author": "Balena Ltd.",
1317
"license": "Apache-2.0",
1418
"devDependencies": {
15-
"@balena/lint": "^9.3.8",
16-
"@types/bluebird": "^3.5.42",
17-
"@types/dockerode": "^3.3.44",
18-
"@types/node": "^16.18.126",
19-
"chai": "^4.5.0",
19+
"@balena/lint": "^9.3.12",
20+
"@types/dockerode": "^4.0.1",
21+
"@types/node": "^22.19.8",
22+
"chai": "^6.2.2",
2023
"chai-events": "0.0.3",
2124
"chai-stream": "0.0.0",
2225
"husky": "^9.1.7",
2326
"JSONStream": "^1.3.5",
24-
"lint-staged": "^16.2.3",
25-
"mocha": "^11.7.4",
27+
"lint-staged": "^16.2.7",
28+
"mocha": "^11.7.5",
2629
"typescript": "^5.9.3"
2730
},
2831
"dependencies": {
29-
"bluebird": "^3.7.2",
30-
"docker-toolbelt": "^6.0.13",
32+
"docker-toolbelt": "^7.0.0",
3133
"dockerode": "^4.0.9",
34+
"p-timeout": "^7.0.1",
3235
"tmp-promise": "^3.0.3",
3336
"typed-error": "^3.2.2"
3437
},

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -o errexit
33

44
function cleanup() {

test/docker-delta.spec.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/* eslint-disable @typescript-eslint/no-require-imports */
2-
const { describe, before, it } = require('mocha');
3-
const chai = require('chai');
1+
import { describe, before, it } from 'mocha';
2+
import * as chai from 'chai';
43

5-
chai.use(require('chai-events'));
6-
chai.use(require('chai-stream'));
4+
import chaiEvents from 'chai-events';
5+
import chaiStream from 'chai-stream';
6+
chai.use(chaiEvents);
7+
chai.use(chaiStream);
78

8-
const JSONStream = require('JSONStream');
9-
const stream = require('node:stream');
10-
const Dockerode = require('dockerode');
9+
import JSONStream from 'JSONStream';
10+
import stream from 'node:stream';
11+
import Dockerode from 'dockerode';
1112

1213
const docker = new Dockerode();
1314

14-
const dockerDelta = require('..');
15+
import * as dockerDelta from '../out/docker-delta.js';
1516

1617
const { expect } = chai;
1718

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "Node16",
3+
"module": "Node20",
44
"strict": true,
55
"noUnusedParameters": true,
66
"noUnusedLocals": true,
@@ -9,7 +9,7 @@
99
"removeComments": true,
1010
"rootDir": "lib",
1111
"sourceMap": true,
12-
"target": "es2022",
12+
"target": "es2024",
1313
"declaration": true,
1414
"skipLibCheck": true,
1515
"resolveJsonModule": true,

0 commit comments

Comments
 (0)