@quatrain/worker 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FileSystem.test.js +18 -5
- package/dist/Helpers.d.ts +2 -1
- package/dist/Helpers.js +7 -1
- package/package.json +3 -3
- package/src/FileSystem.test.ts +18 -7
- package/src/Helpers.ts +8 -1
package/dist/FileSystem.test.js
CHANGED
|
@@ -44,7 +44,14 @@ const node_fetch_native_1 = __importDefault(require("node-fetch-native"));
|
|
|
44
44
|
const ffmpeg = __importStar(require("fluent-ffmpeg"));
|
|
45
45
|
const node_stream_1 = require("node:stream");
|
|
46
46
|
jest.mock('axios');
|
|
47
|
-
jest.mock('node-fetch-native')
|
|
47
|
+
jest.mock('node-fetch-native', () => {
|
|
48
|
+
const fn = jest.fn();
|
|
49
|
+
return {
|
|
50
|
+
__esModule: true,
|
|
51
|
+
default: fn,
|
|
52
|
+
fetch: fn,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
48
55
|
jest.mock('fluent-ffmpeg', () => ({
|
|
49
56
|
ffprobe: jest.fn()
|
|
50
57
|
}));
|
|
@@ -105,15 +112,21 @@ describe('FileSystem Utilities (Worker)', () => {
|
|
|
105
112
|
return (jest.requireActual('node:fs').statSync)(p);
|
|
106
113
|
});
|
|
107
114
|
// Setup base temp folder if needed
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
try {
|
|
116
|
+
if (originalExistsSync(testBaseDir)) {
|
|
117
|
+
node_fs_1.default.rmSync(testBaseDir, { recursive: true, force: true });
|
|
118
|
+
}
|
|
110
119
|
}
|
|
120
|
+
catch { }
|
|
111
121
|
});
|
|
112
122
|
afterEach(() => {
|
|
113
123
|
// Clean up base temp folder
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
try {
|
|
125
|
+
if (originalExistsSync(testBaseDir)) {
|
|
126
|
+
node_fs_1.default.rmSync(testBaseDir, { recursive: true, force: true });
|
|
127
|
+
}
|
|
116
128
|
}
|
|
129
|
+
catch { }
|
|
117
130
|
jest.clearAllMocks();
|
|
118
131
|
jest.restoreAllMocks();
|
|
119
132
|
});
|
package/dist/Helpers.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* General utility class providing common static helpers for workers.
|
|
3
3
|
*/
|
|
4
4
|
export declare class Helpers {
|
|
5
|
+
private static _ffmpegPathPromise;
|
|
5
6
|
/** Default absolute path to the system's FFmpeg binary. */
|
|
6
|
-
static FFMPEG: Promise<string>;
|
|
7
|
+
static get FFMPEG(): Promise<string>;
|
|
7
8
|
/**
|
|
8
9
|
* Generate a thubnail from a video file at given frame position
|
|
9
10
|
* @param videoPath path to video file
|
package/dist/Helpers.js
CHANGED
|
@@ -6,8 +6,14 @@ const Worker_1 = require("./Worker");
|
|
|
6
6
|
* General utility class providing common static helpers for workers.
|
|
7
7
|
*/
|
|
8
8
|
class Helpers {
|
|
9
|
+
static _ffmpegPathPromise = null;
|
|
9
10
|
/** Default absolute path to the system's FFmpeg binary. */
|
|
10
|
-
static FFMPEG
|
|
11
|
+
static get FFMPEG() {
|
|
12
|
+
if (!this._ffmpegPathPromise) {
|
|
13
|
+
this._ffmpegPathPromise = Worker_1.Worker.getSystemCommandPath('ffmpeg').catch(() => 'ffmpeg');
|
|
14
|
+
}
|
|
15
|
+
return this._ffmpegPathPromise;
|
|
16
|
+
}
|
|
11
17
|
/**
|
|
12
18
|
* Generate a thubnail from a video file at given frame position
|
|
13
19
|
* @param videoPath path to video file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/worker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Container Worker helpers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"typescript": "^5.1.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@quatrain/core": "^1.2.
|
|
37
|
+
"@quatrain/core": "^1.2.17",
|
|
38
38
|
"@quatrain/queue": "^1.2.3",
|
|
39
|
-
"@quatrain/storage": "^1.2.
|
|
39
|
+
"@quatrain/storage": "^1.2.13",
|
|
40
40
|
"axios": "^1.7.7",
|
|
41
41
|
"fluent-ffmpeg": "^2.1.2",
|
|
42
42
|
"fs-extra": "^11.2.0",
|
package/src/FileSystem.test.ts
CHANGED
|
@@ -7,7 +7,14 @@ import * as ffmpeg from 'fluent-ffmpeg'
|
|
|
7
7
|
import { PassThrough, Readable } from 'node:stream'
|
|
8
8
|
|
|
9
9
|
jest.mock('axios')
|
|
10
|
-
jest.mock('node-fetch-native')
|
|
10
|
+
jest.mock('node-fetch-native', () => {
|
|
11
|
+
const fn = jest.fn()
|
|
12
|
+
return {
|
|
13
|
+
__esModule: true,
|
|
14
|
+
default: fn,
|
|
15
|
+
fetch: fn,
|
|
16
|
+
}
|
|
17
|
+
})
|
|
11
18
|
jest.mock('fluent-ffmpeg', () => ({
|
|
12
19
|
ffprobe: jest.fn()
|
|
13
20
|
}))
|
|
@@ -76,16 +83,20 @@ describe('FileSystem Utilities (Worker)', () => {
|
|
|
76
83
|
})
|
|
77
84
|
|
|
78
85
|
// Setup base temp folder if needed
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
try {
|
|
87
|
+
if (originalExistsSync(testBaseDir)) {
|
|
88
|
+
fs.rmSync(testBaseDir, { recursive: true, force: true })
|
|
89
|
+
}
|
|
90
|
+
} catch {}
|
|
82
91
|
})
|
|
83
92
|
|
|
84
93
|
afterEach(() => {
|
|
85
94
|
// Clean up base temp folder
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
try {
|
|
96
|
+
if (originalExistsSync(testBaseDir)) {
|
|
97
|
+
fs.rmSync(testBaseDir, { recursive: true, force: true })
|
|
98
|
+
}
|
|
99
|
+
} catch {}
|
|
89
100
|
jest.clearAllMocks()
|
|
90
101
|
jest.restoreAllMocks()
|
|
91
102
|
})
|
package/src/Helpers.ts
CHANGED
|
@@ -5,8 +5,15 @@ import path from 'node:path'
|
|
|
5
5
|
* General utility class providing common static helpers for workers.
|
|
6
6
|
*/
|
|
7
7
|
export class Helpers {
|
|
8
|
+
private static _ffmpegPathPromise: Promise<string> | null = null
|
|
9
|
+
|
|
8
10
|
/** Default absolute path to the system's FFmpeg binary. */
|
|
9
|
-
static FFMPEG
|
|
11
|
+
static get FFMPEG(): Promise<string> {
|
|
12
|
+
if (!this._ffmpegPathPromise) {
|
|
13
|
+
this._ffmpegPathPromise = Worker.getSystemCommandPath('ffmpeg').catch(() => 'ffmpeg')
|
|
14
|
+
}
|
|
15
|
+
return this._ffmpegPathPromise
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* Generate a thubnail from a video file at given frame position
|