From 44e7388d8e03823cebc2754343c116281463fe1f Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Thu, 27 Jun 2024 11:52:19 +0200 Subject: [PATCH] Check for long arg file names --- npm/index.js | 8 ++++++-- npm/test.js | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/npm/index.js b/npm/index.js index 2957a6b8..bed7bdf8 100644 --- a/npm/index.js +++ b/npm/index.js @@ -272,8 +272,12 @@ async function read(fd = 0) { } function isFile(fs, path) { - const stat = fs.statSync(path, {throwIfNoEntry: false}) - return stat !== undefined && stat.isFile() + try { + const stat = fs.statSync(path, {throwIfNoEntry: false}) + return stat !== undefined && stat.isFile() + } catch (err) { + return false + } } function sleepSync(ms) { diff --git a/npm/test.js b/npm/test.js index bf096b5f..686b158e 100644 --- a/npm/test.js +++ b/npm/test.js @@ -221,4 +221,10 @@ void async function main() { const {stdout} = await runNoPipe(`.name package.json`) t.equal(stdout, 'fx\n') }) + + await test('cli - very large arg', async t => { + const {status, stderr, stdout} = await run(42, `'x => x /* dsasdfaskjdfhaskldjfhgaslkdjfhasdlkfjhasdlkfjhasdlfkjhasdflkjasdhflkjasdhflacnskdcfhalsdkfjhasldkfjhcasdlckfajhdsflbkasjdhfclnaskdjhfalskdfgjhsdflkfjhasdlfkahjsdflkasjhdflkafdggrhdfggsdfghsdghadfgsdfgsdfglhadshfglaksjdfhalskjdfhasldkfjhaldfkjhasdlfkjhasdflkjhadflkhasdlkfjhdfkhjasdlfkjhasdflkhaflkcansdfhvlkvajhfgvbalergtcqwaleifhavslbkfchasdblkfhldsfhasdfasfasdfdfdddddddadlakfjhas */'`) + t.equal(status, 0, stderr) + t.equal(stdout, '42\n') + }) }()