33const fs = require ( 'fs' ) ;
44const os = require ( 'os' ) ;
55const path = require ( 'path' ) ;
6- const uuid = require ( 'uuid ' ) ;
6+ const { randomUUID } = require ( 'node:crypto ' ) ;
77const compressing = require ( '../..' ) ;
88const assert = require ( 'assert' ) ;
99const isWindows = os . platform ( ) === 'win32' ;
@@ -12,7 +12,7 @@ describe('test/gzip/index.test.js', () => {
1212 describe ( 'gzip.compressFile()' , ( ) => {
1313 it ( 'gzip.compressFile(file, stream)' , async ( ) => {
1414 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
15- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log.gz' ) ;
15+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log.gz' ) ;
1616 // console.log('destFile', destFile);
1717 const fileStream = fs . createWriteStream ( destFile ) ;
1818 await compressing . gzip . compressFile ( sourceFile , fileStream ) ;
@@ -21,7 +21,7 @@ describe('test/gzip/index.test.js', () => {
2121
2222 it ( 'gzip.compressFile(file, destStream) should error if destStream emit error' , async ( ) => {
2323 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
24- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.gz' ) ;
24+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.gz' ) ;
2525 const fileStream = fs . createWriteStream ( destFile ) ;
2626 setImmediate ( ( ) => fileStream . emit ( 'error' , new Error ( 'xx' ) ) ) ;
2727
@@ -37,7 +37,7 @@ describe('test/gzip/index.test.js', () => {
3737 it ( 'gzip.compressFile(buffer, stream)' , async ( ) => {
3838 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
3939 const sourceBuffer = fs . readFileSync ( sourceFile ) ;
40- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log.gz' ) ;
40+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log.gz' ) ;
4141 // console.log('destFile', destFile);
4242 const fileStream = fs . createWriteStream ( destFile ) ;
4343 await compressing . gzip . compressFile ( sourceBuffer , fileStream ) ;
@@ -47,7 +47,7 @@ describe('test/gzip/index.test.js', () => {
4747 it ( 'gzip.compressFile(sourceStream, destStream)' , async ( ) => {
4848 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
4949 const sourceStream = fs . createReadStream ( sourceFile ) ;
50- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log.gz' ) ;
50+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log.gz' ) ;
5151 // console.log('destFile', destFile);
5252 const fileStream = fs . createWriteStream ( destFile ) ;
5353 await compressing . gzip . compressFile ( sourceStream , fileStream ) ;
@@ -59,7 +59,7 @@ describe('test/gzip/index.test.js', () => {
5959 it ( 'gzip.uncompress(sourceFile, destStream)' , async ( ) => {
6060 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log.gz' ) ;
6161 const originalFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
62- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log' ) ;
62+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log' ) ;
6363 const fileStream = fs . createWriteStream ( destFile ) ;
6464 await compressing . gzip . uncompress ( sourceFile , fileStream ) ;
6565 assert ( fs . existsSync ( destFile ) ) ;
@@ -72,7 +72,7 @@ describe('test/gzip/index.test.js', () => {
7272 it ( 'gzip.uncompress(sourceStream, destStream)' , async ( ) => {
7373 const sourceStream = fs . createReadStream ( path . join ( __dirname , '..' , 'fixtures' , 'xx.log.gz' ) ) ;
7474 const originalFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
75- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log' ) ;
75+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log' ) ;
7676 const fileStream = fs . createWriteStream ( destFile ) ;
7777 await compressing . gzip . uncompress ( sourceStream , fileStream ) ;
7878 assert ( fs . existsSync ( destFile ) ) ;
@@ -85,7 +85,7 @@ describe('test/gzip/index.test.js', () => {
8585 it ( 'gzip.uncompress(sourceStream, destFile)' , async ( ) => {
8686 const sourceStream = fs . createReadStream ( path . join ( __dirname , '..' , 'fixtures' , 'xx.log.gz' ) ) ;
8787 const originalFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
88- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log' ) ;
88+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log' ) ;
8989 await compressing . gzip . uncompress ( sourceStream , destFile ) ;
9090 assert ( fs . existsSync ( destFile ) ) ;
9191 if ( ! isWindows ) {
@@ -97,7 +97,7 @@ describe('test/gzip/index.test.js', () => {
9797 it ( 'gzip.uncompress(sourceFile, destFile)' , async ( ) => {
9898 const sourceFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log.gz' ) ;
9999 const originalFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
100- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log' ) ;
100+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log' ) ;
101101 await compressing . gzip . uncompress ( sourceFile , destFile ) ;
102102 assert ( fs . existsSync ( destFile ) ) ;
103103 if ( ! isWindows ) {
@@ -109,7 +109,7 @@ describe('test/gzip/index.test.js', () => {
109109 it ( 'gzip.uncompress(buffer, destFile)' , async ( ) => {
110110 const sourceBuffer = fs . readFileSync ( path . join ( __dirname , '..' , 'fixtures' , 'xx.log.gz' ) ) ;
111111 const originalFile = path . join ( __dirname , '..' , 'fixtures' , 'xx.log' ) ;
112- const destFile = path . join ( os . tmpdir ( ) , uuid . v4 ( ) + '.log' ) ;
112+ const destFile = path . join ( os . tmpdir ( ) , randomUUID ( ) + '.log' ) ;
113113 await compressing . gzip . uncompress ( sourceBuffer , destFile ) ;
114114 assert ( fs . existsSync ( destFile ) ) ;
115115 if ( ! isWindows ) {
0 commit comments