@@ -4,6 +4,7 @@ const { spawnPromisified } = require('../common');
44const fixtures = require ( '../common/fixtures' ) ;
55const { match, strictEqual } = require ( 'node:assert' ) ;
66const { test } = require ( 'node:test' ) ;
7+ const { chmodSync } = require ( 'node:fs' ) ;
78
89test ( 'should handle non existing json' , async ( ) => {
910 const result = await spawnPromisified ( process . execPath , [
@@ -282,3 +283,17 @@ test('should override node.json when specificied', async () => {
282283 strictEqual ( result . stdout , '20\n' ) ;
283284 strictEqual ( result . code , 0 ) ;
284285} ) ;
286+
287+ test ( 'should throw an error when the file is non readable' , async ( ) => {
288+ chmodSync ( fixtures . path ( 'rc/non-readable/node.json' ) , '000' ) ;
289+ const result = await spawnPromisified ( process . execPath , [
290+ '--no-warnings' ,
291+ '--experimental-config-file' ,
292+ '-p' , 'http.maxHeaderSize' ,
293+ ] , {
294+ cwd : fixtures . path ( 'rc/non-readable' ) ,
295+ } ) ;
296+ match ( result . stderr , / C a n n o t r e a d c o n f i g u r a t i o n f r o m n o d e \. j s o n : p e r m i s s i o n d e n i e d / ) ;
297+ strictEqual ( result . stdout , '' ) ;
298+ strictEqual ( result . code , 9 ) ;
299+ } ) ;
0 commit comments