Skip to content

Commit e08d7d4

Browse files
jasnelltargos
authored andcommitted
lib: fixup incorrect argument order in assertEncoding
PR-URL: #57177 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 455bf5a commit e08d7d4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎lib/internal/fs/utils.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function lazyLoadFs(){
154154
functionassertEncoding(encoding){
155155
if(encoding&&!Buffer.isEncoding(encoding)){
156156
constreason='is invalid encoding';
157-
thrownewERR_INVALID_ARG_VALUE(encoding,'encoding',reason);
157+
thrownewERR_INVALID_ARG_VALUE('encoding',encoding,reason);
158158
}
159159
}
160160

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
// Tests to verify that a correctly formatted invalid encoding error
4+
// is thrown. Originally the internal assertEncoding utility was
5+
// reversing the arguments when constructing the ERR_INVALID_ARG_VALUE
6+
// error.
7+
8+
require('../common');
9+
const{ opendirSync }=require('node:fs');
10+
const{ throws }=require('node:assert');
11+
12+
throws(()=>opendirSync('.',{encoding: 'no'}),{
13+
code: 'ERR_INVALID_ARG_VALUE',
14+
message: 'The argument \'encoding\' is invalid encoding. Received \'no\'',
15+
});

0 commit comments

Comments
(0)