mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
readFileSync, writeFileSync, appendFileSync, statSync, lstatSync, readdirSync, mkdirSync, rmSync, rmdirSync, mkdtempSync, accessSync, unlinkSync, chmodSync, chownSync, lchownSync, truncateSync, copyFileSync, renameSync, realpathSync, realpathSync.native, openSync and opendirSync accept a file: URL wherever they accept a path. The URL converts as fileURLToPath converts it, with Node's errors for other schemes, hosts, encoded separators and null bytes. Arguments after a URL path that have side effects are evaluated into hidden locals before the conversion, so they run even when it throws. A URL path after a string path, or with options that are not literals, fails with SC2020, because Node checks those arguments before it converts the URL. existsSync and the fs.promises functions also fail with SC2020 for URL paths: existsSync answers false for a URL it cannot convert, and fs.promises reports conversion errors as rejections. Fixes #1616 Co-authored-by: jlucaso1 <55464917+jlucaso1@users.noreply.github.com>