projen 0.71.51 → 0.71.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/.jsii +3 -3
  2. package/lib/awscdk/auto-discover.js +5 -5
  3. package/lib/awscdk/awscdk-app-java.js +1 -1
  4. package/lib/awscdk/awscdk-app-py.js +1 -1
  5. package/lib/awscdk/awscdk-app-ts.js +1 -1
  6. package/lib/awscdk/awscdk-construct.js +2 -2
  7. package/lib/awscdk/awscdk-deps-java.js +1 -1
  8. package/lib/awscdk/awscdk-deps-js.js +1 -1
  9. package/lib/awscdk/awscdk-deps-py.js +1 -1
  10. package/lib/awscdk/awscdk-deps.js +1 -1
  11. package/lib/awscdk/cdk-config.js +1 -1
  12. package/lib/awscdk/cdk-tasks.js +1 -1
  13. package/lib/awscdk/integration-test.js +1 -1
  14. package/lib/awscdk/lambda-extension.js +1 -1
  15. package/lib/awscdk/lambda-function.js +2 -2
  16. package/lib/build/build-workflow.js +1 -1
  17. package/lib/cdk/auto-discover-base.js +2 -2
  18. package/lib/cdk/construct-lib.js +1 -1
  19. package/lib/cdk/integration-test-base.js +1 -1
  20. package/lib/cdk/jsii-docgen.js +1 -1
  21. package/lib/cdk/jsii-project.js +1 -1
  22. package/lib/cdk8s/auto-discover.js +2 -2
  23. package/lib/cdk8s/cdk8s-app-py.js +1 -1
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps.js +1 -1
  28. package/lib/cdk8s/integration-test.js +1 -1
  29. package/lib/cdktf/cdktf-construct.js +1 -1
  30. package/lib/circleci/circleci.js +1 -1
  31. package/lib/component.js +1 -1
  32. package/lib/dependencies.js +1 -1
  33. package/lib/dev-env.js +1 -1
  34. package/lib/docker-compose/docker-compose-service.js +1 -1
  35. package/lib/docker-compose/docker-compose.js +1 -1
  36. package/lib/file.js +1 -1
  37. package/lib/gitattributes.js +1 -1
  38. package/lib/github/actions-provider.js +1 -1
  39. package/lib/github/auto-approve.js +1 -1
  40. package/lib/github/auto-merge.js +1 -1
  41. package/lib/github/dependabot.js +1 -1
  42. package/lib/github/github-credentials.js +1 -1
  43. package/lib/github/github-project.js +1 -1
  44. package/lib/github/github.js +1 -1
  45. package/lib/github/mergify.js +1 -1
  46. package/lib/github/pr-template.js +1 -1
  47. package/lib/github/pull-request-lint.js +1 -1
  48. package/lib/github/stale.js +1 -1
  49. package/lib/github/task-workflow.js +1 -1
  50. package/lib/github/workflow-actions.js +1 -1
  51. package/lib/github/workflow-jobs.js +1 -1
  52. package/lib/github/workflows.js +1 -1
  53. package/lib/gitlab/configuration.js +1 -1
  54. package/lib/gitlab/gitlab-configuration.js +1 -1
  55. package/lib/gitlab/nested-configuration.js +1 -1
  56. package/lib/gitpod.js +1 -1
  57. package/lib/ignore-file.js +1 -1
  58. package/lib/ini.js +1 -1
  59. package/lib/java/java-project.js +1 -1
  60. package/lib/java/junit.js +1 -1
  61. package/lib/java/maven-compile.js +1 -1
  62. package/lib/java/maven-packaging.js +1 -1
  63. package/lib/java/maven-sample.js +1 -1
  64. package/lib/java/pom.js +1 -1
  65. package/lib/java/projenrc.js +1 -1
  66. package/lib/javascript/bundler.js +1 -1
  67. package/lib/javascript/eslint.js +1 -1
  68. package/lib/javascript/jest.js +4 -4
  69. package/lib/javascript/node-package.js +1 -1
  70. package/lib/javascript/node-project.js +1 -1
  71. package/lib/javascript/npm-config.js +1 -1
  72. package/lib/javascript/prettier.js +1 -1
  73. package/lib/javascript/projenrc.js +1 -1
  74. package/lib/javascript/typescript-config.js +2 -2
  75. package/lib/javascript/upgrade-dependencies.js +2 -2
  76. package/lib/json-patch.js +1 -1
  77. package/lib/json.js +1 -1
  78. package/lib/license.js +1 -1
  79. package/lib/logger.js +1 -1
  80. package/lib/makefile.js +1 -1
  81. package/lib/object-file.js +1 -1
  82. package/lib/project-build.js +1 -1
  83. package/lib/project.js +1 -1
  84. package/lib/projects.js +1 -1
  85. package/lib/projenrc-json.js +2 -2
  86. package/lib/projenrc.js +1 -1
  87. package/lib/python/pip.js +1 -1
  88. package/lib/python/poetry.js +2 -2
  89. package/lib/python/projenrc.js +1 -1
  90. package/lib/python/pytest-sample.js +1 -1
  91. package/lib/python/pytest.js +1 -1
  92. package/lib/python/python-project.js +1 -1
  93. package/lib/python/python-sample.js +1 -1
  94. package/lib/python/requirements-file.js +1 -1
  95. package/lib/python/setuppy.js +1 -1
  96. package/lib/python/setuptools.js +1 -1
  97. package/lib/python/venv.js +1 -1
  98. package/lib/readme.js +1 -1
  99. package/lib/release/publisher.js +1 -1
  100. package/lib/release/release-trigger.js +1 -1
  101. package/lib/release/release.js +1 -1
  102. package/lib/renovatebot.js +1 -1
  103. package/lib/sample-file.js +2 -2
  104. package/lib/semver.js +1 -1
  105. package/lib/source-code.js +1 -1
  106. package/lib/task-runtime.js +1 -1
  107. package/lib/task.js +1 -1
  108. package/lib/tasks.js +1 -1
  109. package/lib/testing.js +1 -1
  110. package/lib/textfile.js +1 -1
  111. package/lib/toml.js +1 -1
  112. package/lib/typescript/projenrc-ts.js +1 -1
  113. package/lib/typescript/projenrc.js +1 -1
  114. package/lib/typescript/typescript-typedoc.js +1 -1
  115. package/lib/typescript/typescript.js +3 -3
  116. package/lib/version.js +1 -1
  117. package/lib/vscode/devcontainer.js +1 -1
  118. package/lib/vscode/extensions.js +1 -1
  119. package/lib/vscode/launch-config.js +1 -1
  120. package/lib/vscode/settings.js +1 -1
  121. package/lib/vscode/vscode.js +1 -1
  122. package/lib/web/next.js +3 -3
  123. package/lib/web/postcss.js +1 -1
  124. package/lib/web/react.js +4 -4
  125. package/lib/web/tailwind.js +1 -1
  126. package/lib/xmlfile.js +1 -1
  127. package/lib/yaml.js +1 -1
  128. package/node_modules/@oozcitak/dom/LICENSE +21 -21
  129. package/node_modules/@oozcitak/dom/README.md +32 -32
  130. package/node_modules/@oozcitak/dom/lib/parser/XMLParserImpl.d.ts +12 -0
  131. package/node_modules/@oozcitak/dom/lib/parser/XMLParserImpl.js +23 -3
  132. package/node_modules/@oozcitak/dom/lib/parser/XMLParserImpl.js.map +1 -1
  133. package/node_modules/@oozcitak/dom/package.json +72 -72
  134. package/node_modules/xmlbuilder2/CHANGELOG.md +95 -1
  135. package/node_modules/xmlbuilder2/README.md +5 -4
  136. package/node_modules/xmlbuilder2/lib/builder/XMLBuilderCBImpl.d.ts +3 -1
  137. package/node_modules/xmlbuilder2/lib/builder/XMLBuilderCBImpl.js +44 -53
  138. package/node_modules/xmlbuilder2/lib/builder/XMLBuilderCBImpl.js.map +1 -1
  139. package/node_modules/xmlbuilder2/lib/constants.d.ts +1 -0
  140. package/node_modules/xmlbuilder2/lib/constants.js +4 -0
  141. package/node_modules/xmlbuilder2/lib/constants.js.map +1 -0
  142. package/node_modules/xmlbuilder2/lib/interfaces.d.ts +20 -8
  143. package/node_modules/xmlbuilder2/lib/interfaces.js +1 -0
  144. package/node_modules/xmlbuilder2/lib/interfaces.js.map +1 -1
  145. package/node_modules/xmlbuilder2/lib/readers/BaseReader.d.ts +14 -1
  146. package/node_modules/xmlbuilder2/lib/readers/BaseReader.js +30 -1
  147. package/node_modules/xmlbuilder2/lib/readers/BaseReader.js.map +1 -1
  148. package/node_modules/xmlbuilder2/lib/readers/ObjectReader.js +12 -5
  149. package/node_modules/xmlbuilder2/lib/readers/ObjectReader.js.map +1 -1
  150. package/node_modules/xmlbuilder2/lib/readers/XMLReader.js +11 -5
  151. package/node_modules/xmlbuilder2/lib/readers/XMLReader.js.map +1 -1
  152. package/node_modules/xmlbuilder2/lib/writers/BaseWriter.d.ts +1 -1
  153. package/node_modules/xmlbuilder2/lib/writers/BaseWriter.js +58 -92
  154. package/node_modules/xmlbuilder2/lib/writers/BaseWriter.js.map +1 -1
  155. package/node_modules/xmlbuilder2/lib/writers/JSONWriter.js +1 -3
  156. package/node_modules/xmlbuilder2/lib/writers/JSONWriter.js.map +1 -1
  157. package/node_modules/xmlbuilder2/lib/writers/MapWriter.js +0 -2
  158. package/node_modules/xmlbuilder2/lib/writers/MapWriter.js.map +1 -1
  159. package/node_modules/xmlbuilder2/lib/writers/ObjectWriter.js +1 -2
  160. package/node_modules/xmlbuilder2/lib/writers/ObjectWriter.js.map +1 -1
  161. package/node_modules/xmlbuilder2/lib/writers/XMLWriter.js +1 -2
  162. package/node_modules/xmlbuilder2/lib/writers/XMLWriter.js.map +1 -1
  163. package/node_modules/xmlbuilder2/lib/writers/YAMLWriter.js +1 -3
  164. package/node_modules/xmlbuilder2/lib/writers/YAMLWriter.js.map +1 -1
  165. package/node_modules/xmlbuilder2/lib/xmlbuilder2.min.js +2 -2
  166. package/node_modules/xmlbuilder2/node_modules/js-yaml/CHANGELOG.md +6 -0
  167. package/node_modules/xmlbuilder2/node_modules/js-yaml/dist/js-yaml.js +2 -2
  168. package/node_modules/xmlbuilder2/node_modules/js-yaml/dist/js-yaml.min.js +1 -1
  169. package/node_modules/xmlbuilder2/node_modules/js-yaml/lib/js-yaml/loader.js +1 -1
  170. package/node_modules/xmlbuilder2/node_modules/js-yaml/package.json +1 -1
  171. package/node_modules/xmlbuilder2/package.json +7 -7
  172. package/package.json +2 -2
  173. package/node_modules/@oozcitak/dom/lib/serializer/XMLSerializerImpl2.d.ts +0 -2
  174. package/node_modules/@oozcitak/dom/lib/serializer/XMLSerializerImpl2.js +0 -962
  175. package/node_modules/@oozcitak/dom/lib/serializer/XMLSerializerImpl2.js.map +0 -1
  176. package/node_modules/xmlbuilder2/node_modules/@types/node/LICENSE +0 -21
  177. package/node_modules/xmlbuilder2/node_modules/@types/node/README.md +0 -16
  178. package/node_modules/xmlbuilder2/node_modules/@types/node/assert/strict.d.ts +0 -8
  179. package/node_modules/xmlbuilder2/node_modules/@types/node/assert.d.ts +0 -957
  180. package/node_modules/xmlbuilder2/node_modules/@types/node/async_hooks.d.ts +0 -538
  181. package/node_modules/xmlbuilder2/node_modules/@types/node/buffer.d.ts +0 -2348
  182. package/node_modules/xmlbuilder2/node_modules/@types/node/child_process.d.ts +0 -1368
  183. package/node_modules/xmlbuilder2/node_modules/@types/node/cluster.d.ts +0 -410
  184. package/node_modules/xmlbuilder2/node_modules/@types/node/console.d.ts +0 -412
  185. package/node_modules/xmlbuilder2/node_modules/@types/node/constants.d.ts +0 -18
  186. package/node_modules/xmlbuilder2/node_modules/@types/node/crypto.d.ts +0 -3962
  187. package/node_modules/xmlbuilder2/node_modules/@types/node/dgram.d.ts +0 -545
  188. package/node_modules/xmlbuilder2/node_modules/@types/node/diagnostics_channel.d.ts +0 -191
  189. package/node_modules/xmlbuilder2/node_modules/@types/node/dns/promises.d.ts +0 -370
  190. package/node_modules/xmlbuilder2/node_modules/@types/node/dns.d.ts +0 -667
  191. package/node_modules/xmlbuilder2/node_modules/@types/node/dom-events.d.ts +0 -126
  192. package/node_modules/xmlbuilder2/node_modules/@types/node/domain.d.ts +0 -170
  193. package/node_modules/xmlbuilder2/node_modules/@types/node/events.d.ts +0 -682
  194. package/node_modules/xmlbuilder2/node_modules/@types/node/fs/promises.d.ts +0 -1189
  195. package/node_modules/xmlbuilder2/node_modules/@types/node/fs.d.ts +0 -4011
  196. package/node_modules/xmlbuilder2/node_modules/@types/node/globals.d.ts +0 -302
  197. package/node_modules/xmlbuilder2/node_modules/@types/node/globals.global.d.ts +0 -1
  198. package/node_modules/xmlbuilder2/node_modules/@types/node/http.d.ts +0 -1724
  199. package/node_modules/xmlbuilder2/node_modules/@types/node/http2.d.ts +0 -2129
  200. package/node_modules/xmlbuilder2/node_modules/@types/node/https.d.ts +0 -441
  201. package/node_modules/xmlbuilder2/node_modules/@types/node/index.d.ts +0 -134
  202. package/node_modules/xmlbuilder2/node_modules/@types/node/inspector.d.ts +0 -2748
  203. package/node_modules/xmlbuilder2/node_modules/@types/node/module.d.ts +0 -116
  204. package/node_modules/xmlbuilder2/node_modules/@types/node/net.d.ts +0 -886
  205. package/node_modules/xmlbuilder2/node_modules/@types/node/os.d.ts +0 -477
  206. package/node_modules/xmlbuilder2/node_modules/@types/node/package.json +0 -237
  207. package/node_modules/xmlbuilder2/node_modules/@types/node/path.d.ts +0 -191
  208. package/node_modules/xmlbuilder2/node_modules/@types/node/perf_hooks.d.ts +0 -638
  209. package/node_modules/xmlbuilder2/node_modules/@types/node/process.d.ts +0 -1485
  210. package/node_modules/xmlbuilder2/node_modules/@types/node/punycode.d.ts +0 -117
  211. package/node_modules/xmlbuilder2/node_modules/@types/node/querystring.d.ts +0 -131
  212. package/node_modules/xmlbuilder2/node_modules/@types/node/readline/promises.d.ts +0 -145
  213. package/node_modules/xmlbuilder2/node_modules/@types/node/readline.d.ts +0 -653
  214. package/node_modules/xmlbuilder2/node_modules/@types/node/repl.d.ts +0 -424
  215. package/node_modules/xmlbuilder2/node_modules/@types/node/stream/consumers.d.ts +0 -12
  216. package/node_modules/xmlbuilder2/node_modules/@types/node/stream/promises.d.ts +0 -42
  217. package/node_modules/xmlbuilder2/node_modules/@types/node/stream/web.d.ts +0 -330
  218. package/node_modules/xmlbuilder2/node_modules/@types/node/stream.d.ts +0 -1392
  219. package/node_modules/xmlbuilder2/node_modules/@types/node/string_decoder.d.ts +0 -67
  220. package/node_modules/xmlbuilder2/node_modules/@types/node/test.d.ts +0 -997
  221. package/node_modules/xmlbuilder2/node_modules/@types/node/timers/promises.d.ts +0 -93
  222. package/node_modules/xmlbuilder2/node_modules/@types/node/timers.d.ts +0 -101
  223. package/node_modules/xmlbuilder2/node_modules/@types/node/tls.d.ts +0 -1119
  224. package/node_modules/xmlbuilder2/node_modules/@types/node/trace_events.d.ts +0 -182
  225. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  226. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/assert.d.ts +0 -957
  227. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -538
  228. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2348
  229. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1368
  230. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/cluster.d.ts +0 -410
  231. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/console.d.ts +0 -412
  232. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/constants.d.ts +0 -18
  233. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/crypto.d.ts +0 -3961
  234. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/dgram.d.ts +0 -545
  235. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -191
  236. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -370
  237. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/dns.d.ts +0 -667
  238. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -126
  239. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  240. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/events.d.ts +0 -682
  241. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1189
  242. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/fs.d.ts +0 -4011
  243. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/globals.d.ts +0 -302
  244. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  245. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/http.d.ts +0 -1723
  246. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/http2.d.ts +0 -2129
  247. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/https.d.ts +0 -441
  248. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  249. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2748
  250. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/module.d.ts +0 -116
  251. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/net.d.ts +0 -886
  252. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/os.d.ts +0 -477
  253. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  254. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -638
  255. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/process.d.ts +0 -1485
  256. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  257. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/querystring.d.ts +0 -131
  258. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -145
  259. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/readline.d.ts +0 -653
  260. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/repl.d.ts +0 -424
  261. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  262. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -42
  263. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -330
  264. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/stream.d.ts +0 -1392
  265. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  266. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/test.d.ts +0 -997
  267. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  268. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/timers.d.ts +0 -101
  269. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/tls.d.ts +0 -1119
  270. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  271. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/tty.d.ts +0 -205
  272. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/url.d.ts +0 -892
  273. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/util.d.ts +0 -2044
  274. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/v8.d.ts +0 -635
  275. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/vm.d.ts +0 -894
  276. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/wasi.d.ts +0 -152
  277. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -693
  278. package/node_modules/xmlbuilder2/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  279. package/node_modules/xmlbuilder2/node_modules/@types/node/tty.d.ts +0 -205
  280. package/node_modules/xmlbuilder2/node_modules/@types/node/url.d.ts +0 -892
  281. package/node_modules/xmlbuilder2/node_modules/@types/node/util.d.ts +0 -2052
  282. package/node_modules/xmlbuilder2/node_modules/@types/node/v8.d.ts +0 -635
  283. package/node_modules/xmlbuilder2/node_modules/@types/node/vm.d.ts +0 -894
  284. package/node_modules/xmlbuilder2/node_modules/@types/node/wasi.d.ts +0 -152
  285. package/node_modules/xmlbuilder2/node_modules/@types/node/worker_threads.d.ts +0 -693
  286. package/node_modules/xmlbuilder2/node_modules/@types/node/zlib.d.ts +0 -517
  287. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/CHANGELOG.md +0 -0
  288. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/LICENSE +0 -0
  289. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/README.md +0 -0
  290. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/index.js +0 -0
  291. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/append/constant.js +0 -0
  292. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/append.js +0 -0
  293. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/count.js +0 -0
  294. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/help.js +0 -0
  295. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/store/constant.js +0 -0
  296. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/store/false.js +0 -0
  297. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/store/true.js +0 -0
  298. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/store.js +0 -0
  299. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/subparsers.js +0 -0
  300. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action/version.js +0 -0
  301. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action.js +0 -0
  302. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/action_container.js +0 -0
  303. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/argparse.js +0 -0
  304. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/argument/error.js +0 -0
  305. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/argument/exclusive.js +0 -0
  306. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/argument/group.js +0 -0
  307. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/argument_parser.js +0 -0
  308. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/const.js +0 -0
  309. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/help/added_formatters.js +0 -0
  310. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/help/formatter.js +0 -0
  311. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/namespace.js +0 -0
  312. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/lib/utils.js +0 -0
  313. /package/node_modules/{argparse → xmlbuilder2/node_modules/argparse}/package.json +0 -0
@@ -1,4011 +0,0 @@
1
- /**
2
- * The `node:fs` module enables interacting with the file system in a
3
- * way modeled on standard POSIX functions.
4
- *
5
- * To use the promise-based APIs:
6
- *
7
- * ```js
8
- * import * as fs from 'node:fs/promises';
9
- * ```
10
- *
11
- * To use the callback and sync APIs:
12
- *
13
- * ```js
14
- * import * as fs from 'node:fs';
15
- * ```
16
- *
17
- * All file system operations have synchronous, callback, and promise-based
18
- * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
19
- * @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/fs.js)
20
- */
21
- declare module 'fs' {
22
- import * as stream from 'node:stream';
23
- import { Abortable, EventEmitter } from 'node:events';
24
- import { URL } from 'node:url';
25
- import * as promises from 'node:fs/promises';
26
- export { promises };
27
- /**
28
- * Valid types for path values in "fs".
29
- */
30
- export type PathLike = string | Buffer | URL;
31
- export type PathOrFileDescriptor = PathLike | number;
32
- export type TimeLike = string | number | Date;
33
- export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
34
- export type BufferEncodingOption =
35
- | 'buffer'
36
- | {
37
- encoding: 'buffer';
38
- };
39
- export interface ObjectEncodingOptions {
40
- encoding?: BufferEncoding | null | undefined;
41
- }
42
- export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;
43
- export type OpenMode = number | string;
44
- export type Mode = number | string;
45
- export interface StatsBase<T> {
46
- isFile(): boolean;
47
- isDirectory(): boolean;
48
- isBlockDevice(): boolean;
49
- isCharacterDevice(): boolean;
50
- isSymbolicLink(): boolean;
51
- isFIFO(): boolean;
52
- isSocket(): boolean;
53
- dev: T;
54
- ino: T;
55
- mode: T;
56
- nlink: T;
57
- uid: T;
58
- gid: T;
59
- rdev: T;
60
- size: T;
61
- blksize: T;
62
- blocks: T;
63
- atimeMs: T;
64
- mtimeMs: T;
65
- ctimeMs: T;
66
- birthtimeMs: T;
67
- atime: Date;
68
- mtime: Date;
69
- ctime: Date;
70
- birthtime: Date;
71
- }
72
- export interface Stats extends StatsBase<number> {}
73
- /**
74
- * A `fs.Stats` object provides information about a file.
75
- *
76
- * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and
77
- * their synchronous counterparts are of this type.
78
- * If `bigint` in the `options` passed to those methods is true, the numeric values
79
- * will be `bigint` instead of `number`, and the object will contain additional
80
- * nanosecond-precision properties suffixed with `Ns`.
81
- *
82
- * ```console
83
- * Stats {
84
- * dev: 2114,
85
- * ino: 48064969,
86
- * mode: 33188,
87
- * nlink: 1,
88
- * uid: 85,
89
- * gid: 100,
90
- * rdev: 0,
91
- * size: 527,
92
- * blksize: 4096,
93
- * blocks: 8,
94
- * atimeMs: 1318289051000.1,
95
- * mtimeMs: 1318289051000.1,
96
- * ctimeMs: 1318289051000.1,
97
- * birthtimeMs: 1318289051000.1,
98
- * atime: Mon, 10 Oct 2011 23:24:11 GMT,
99
- * mtime: Mon, 10 Oct 2011 23:24:11 GMT,
100
- * ctime: Mon, 10 Oct 2011 23:24:11 GMT,
101
- * birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
102
- * ```
103
- *
104
- * `bigint` version:
105
- *
106
- * ```console
107
- * BigIntStats {
108
- * dev: 2114n,
109
- * ino: 48064969n,
110
- * mode: 33188n,
111
- * nlink: 1n,
112
- * uid: 85n,
113
- * gid: 100n,
114
- * rdev: 0n,
115
- * size: 527n,
116
- * blksize: 4096n,
117
- * blocks: 8n,
118
- * atimeMs: 1318289051000n,
119
- * mtimeMs: 1318289051000n,
120
- * ctimeMs: 1318289051000n,
121
- * birthtimeMs: 1318289051000n,
122
- * atimeNs: 1318289051000000000n,
123
- * mtimeNs: 1318289051000000000n,
124
- * ctimeNs: 1318289051000000000n,
125
- * birthtimeNs: 1318289051000000000n,
126
- * atime: Mon, 10 Oct 2011 23:24:11 GMT,
127
- * mtime: Mon, 10 Oct 2011 23:24:11 GMT,
128
- * ctime: Mon, 10 Oct 2011 23:24:11 GMT,
129
- * birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
130
- * ```
131
- * @since v0.1.21
132
- */
133
- export class Stats {}
134
- export interface StatsFsBase<T> {
135
- /** Type of file system. */
136
- type: T;
137
- /** Optimal transfer block size. */
138
- bsize: T;
139
- /** Total data blocks in file system. */
140
- blocks: T;
141
- /** Free blocks in file system. */
142
- bfree: T;
143
- /** Available blocks for unprivileged users */
144
- bavail: T;
145
- /** Total file nodes in file system. */
146
- files: T;
147
- /** Free file nodes in file system. */
148
- ffree: T;
149
- }
150
- export interface StatsFs extends StatsFsBase<number> {}
151
- /**
152
- * Provides information about a mounted file system
153
- *
154
- * Objects returned from {@link statfs} and {@link statfsSync} are of this type.
155
- * If `bigint` in the `options` passed to those methods is true, the numeric values
156
- * will be `bigint` instead of `number`.
157
- * @since v18.15.0
158
- */
159
- export class StatsFs {}
160
- export interface BigIntStatsFs extends StatsFsBase<bigint> {}
161
- export interface StatFsOptions {
162
- bigint?: boolean | undefined;
163
- }
164
- /**
165
- * A representation of a directory entry, which can be a file or a subdirectory
166
- * within the directory, as returned by reading from an `fs.Dir`. The
167
- * directory entry is a combination of the file name and file type pairs.
168
- *
169
- * Additionally, when {@link readdir} or {@link readdirSync} is called with
170
- * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
171
- * @since v10.10.0
172
- */
173
- export class Dirent {
174
- /**
175
- * Returns `true` if the `fs.Dirent` object describes a regular file.
176
- * @since v10.10.0
177
- */
178
- isFile(): boolean;
179
- /**
180
- * Returns `true` if the `fs.Dirent` object describes a file system
181
- * directory.
182
- * @since v10.10.0
183
- */
184
- isDirectory(): boolean;
185
- /**
186
- * Returns `true` if the `fs.Dirent` object describes a block device.
187
- * @since v10.10.0
188
- */
189
- isBlockDevice(): boolean;
190
- /**
191
- * Returns `true` if the `fs.Dirent` object describes a character device.
192
- * @since v10.10.0
193
- */
194
- isCharacterDevice(): boolean;
195
- /**
196
- * Returns `true` if the `fs.Dirent` object describes a symbolic link.
197
- * @since v10.10.0
198
- */
199
- isSymbolicLink(): boolean;
200
- /**
201
- * Returns `true` if the `fs.Dirent` object describes a first-in-first-out
202
- * (FIFO) pipe.
203
- * @since v10.10.0
204
- */
205
- isFIFO(): boolean;
206
- /**
207
- * Returns `true` if the `fs.Dirent` object describes a socket.
208
- * @since v10.10.0
209
- */
210
- isSocket(): boolean;
211
- /**
212
- * The file name that this `fs.Dirent` object refers to. The type of this
213
- * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
214
- * @since v10.10.0
215
- */
216
- name: string;
217
- }
218
- /**
219
- * A class representing a directory stream.
220
- *
221
- * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`.
222
- *
223
- * ```js
224
- * import { opendir } from 'node:fs/promises';
225
- *
226
- * try {
227
- * const dir = await opendir('./');
228
- * for await (const dirent of dir)
229
- * console.log(dirent.name);
230
- * } catch (err) {
231
- * console.error(err);
232
- * }
233
- * ```
234
- *
235
- * When using the async iterator, the `fs.Dir` object will be automatically
236
- * closed after the iterator exits.
237
- * @since v12.12.0
238
- */
239
- export class Dir implements AsyncIterable<Dirent> {
240
- /**
241
- * The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`.
242
- * @since v12.12.0
243
- */
244
- readonly path: string;
245
- /**
246
- * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
247
- */
248
- [Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
249
- /**
250
- * Asynchronously close the directory's underlying resource handle.
251
- * Subsequent reads will result in errors.
252
- *
253
- * A promise is returned that will be resolved after the resource has been
254
- * closed.
255
- * @since v12.12.0
256
- */
257
- close(): Promise<void>;
258
- close(cb: NoParamCallback): void;
259
- /**
260
- * Synchronously close the directory's underlying resource handle.
261
- * Subsequent reads will result in errors.
262
- * @since v12.12.0
263
- */
264
- closeSync(): void;
265
- /**
266
- * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
267
- *
268
- * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
269
- *
270
- * Directory entries returned by this function are in no particular order as
271
- * provided by the operating system's underlying directory mechanisms.
272
- * Entries added or removed while iterating over the directory might not be
273
- * included in the iteration results.
274
- * @since v12.12.0
275
- * @return containing {fs.Dirent|null}
276
- */
277
- read(): Promise<Dirent | null>;
278
- read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
279
- /**
280
- * Synchronously read the next directory entry as an `fs.Dirent`. See the
281
- * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.
282
- *
283
- * If there are no more directory entries to read, `null` will be returned.
284
- *
285
- * Directory entries returned by this function are in no particular order as
286
- * provided by the operating system's underlying directory mechanisms.
287
- * Entries added or removed while iterating over the directory might not be
288
- * included in the iteration results.
289
- * @since v12.12.0
290
- */
291
- readSync(): Dirent | null;
292
- }
293
- /**
294
- * Class: fs.StatWatcher
295
- * @since v14.3.0, v12.20.0
296
- * Extends `EventEmitter`
297
- * A successful call to {@link watchFile} method will return a new fs.StatWatcher object.
298
- */
299
- export interface StatWatcher extends EventEmitter {
300
- /**
301
- * When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have
302
- * no effect.
303
- *
304
- * By default, all `fs.StatWatcher` objects are "ref'ed", making it normally
305
- * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been
306
- * called previously.
307
- * @since v14.3.0, v12.20.0
308
- */
309
- ref(): this;
310
- /**
311
- * When called, the active `fs.StatWatcher` object will not require the Node.js
312
- * event loop to remain active. If there is no other activity keeping the
313
- * event loop running, the process may exit before the `fs.StatWatcher` object's
314
- * callback is invoked. Calling `watcher.unref()` multiple times will have
315
- * no effect.
316
- * @since v14.3.0, v12.20.0
317
- */
318
- unref(): this;
319
- }
320
- export interface FSWatcher extends EventEmitter {
321
- /**
322
- * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable.
323
- * @since v0.5.8
324
- */
325
- close(): void;
326
- /**
327
- * events.EventEmitter
328
- * 1. change
329
- * 2. error
330
- */
331
- addListener(event: string, listener: (...args: any[]) => void): this;
332
- addListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
333
- addListener(event: 'error', listener: (error: Error) => void): this;
334
- addListener(event: 'close', listener: () => void): this;
335
- on(event: string, listener: (...args: any[]) => void): this;
336
- on(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
337
- on(event: 'error', listener: (error: Error) => void): this;
338
- on(event: 'close', listener: () => void): this;
339
- once(event: string, listener: (...args: any[]) => void): this;
340
- once(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
341
- once(event: 'error', listener: (error: Error) => void): this;
342
- once(event: 'close', listener: () => void): this;
343
- prependListener(event: string, listener: (...args: any[]) => void): this;
344
- prependListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
345
- prependListener(event: 'error', listener: (error: Error) => void): this;
346
- prependListener(event: 'close', listener: () => void): this;
347
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
348
- prependOnceListener(event: 'change', listener: (eventType: string, filename: string | Buffer) => void): this;
349
- prependOnceListener(event: 'error', listener: (error: Error) => void): this;
350
- prependOnceListener(event: 'close', listener: () => void): this;
351
- }
352
- /**
353
- * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
354
- * @since v0.1.93
355
- */
356
- export class ReadStream extends stream.Readable {
357
- close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
358
- /**
359
- * The number of bytes that have been read so far.
360
- * @since v6.4.0
361
- */
362
- bytesRead: number;
363
- /**
364
- * The path to the file the stream is reading from as specified in the first
365
- * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a
366
- * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.
367
- * @since v0.1.93
368
- */
369
- path: string | Buffer;
370
- /**
371
- * This property is `true` if the underlying file has not been opened yet,
372
- * i.e. before the `'ready'` event is emitted.
373
- * @since v11.2.0, v10.16.0
374
- */
375
- pending: boolean;
376
- /**
377
- * events.EventEmitter
378
- * 1. open
379
- * 2. close
380
- * 3. ready
381
- */
382
- addListener(event: 'close', listener: () => void): this;
383
- addListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
384
- addListener(event: 'end', listener: () => void): this;
385
- addListener(event: 'error', listener: (err: Error) => void): this;
386
- addListener(event: 'open', listener: (fd: number) => void): this;
387
- addListener(event: 'pause', listener: () => void): this;
388
- addListener(event: 'readable', listener: () => void): this;
389
- addListener(event: 'ready', listener: () => void): this;
390
- addListener(event: 'resume', listener: () => void): this;
391
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
392
- on(event: 'close', listener: () => void): this;
393
- on(event: 'data', listener: (chunk: Buffer | string) => void): this;
394
- on(event: 'end', listener: () => void): this;
395
- on(event: 'error', listener: (err: Error) => void): this;
396
- on(event: 'open', listener: (fd: number) => void): this;
397
- on(event: 'pause', listener: () => void): this;
398
- on(event: 'readable', listener: () => void): this;
399
- on(event: 'ready', listener: () => void): this;
400
- on(event: 'resume', listener: () => void): this;
401
- on(event: string | symbol, listener: (...args: any[]) => void): this;
402
- once(event: 'close', listener: () => void): this;
403
- once(event: 'data', listener: (chunk: Buffer | string) => void): this;
404
- once(event: 'end', listener: () => void): this;
405
- once(event: 'error', listener: (err: Error) => void): this;
406
- once(event: 'open', listener: (fd: number) => void): this;
407
- once(event: 'pause', listener: () => void): this;
408
- once(event: 'readable', listener: () => void): this;
409
- once(event: 'ready', listener: () => void): this;
410
- once(event: 'resume', listener: () => void): this;
411
- once(event: string | symbol, listener: (...args: any[]) => void): this;
412
- prependListener(event: 'close', listener: () => void): this;
413
- prependListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
414
- prependListener(event: 'end', listener: () => void): this;
415
- prependListener(event: 'error', listener: (err: Error) => void): this;
416
- prependListener(event: 'open', listener: (fd: number) => void): this;
417
- prependListener(event: 'pause', listener: () => void): this;
418
- prependListener(event: 'readable', listener: () => void): this;
419
- prependListener(event: 'ready', listener: () => void): this;
420
- prependListener(event: 'resume', listener: () => void): this;
421
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
422
- prependOnceListener(event: 'close', listener: () => void): this;
423
- prependOnceListener(event: 'data', listener: (chunk: Buffer | string) => void): this;
424
- prependOnceListener(event: 'end', listener: () => void): this;
425
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
426
- prependOnceListener(event: 'open', listener: (fd: number) => void): this;
427
- prependOnceListener(event: 'pause', listener: () => void): this;
428
- prependOnceListener(event: 'readable', listener: () => void): this;
429
- prependOnceListener(event: 'ready', listener: () => void): this;
430
- prependOnceListener(event: 'resume', listener: () => void): this;
431
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
432
- }
433
- /**
434
- * * Extends `stream.Writable`
435
- *
436
- * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.
437
- * @since v0.1.93
438
- */
439
- export class WriteStream extends stream.Writable {
440
- /**
441
- * Closes `writeStream`. Optionally accepts a
442
- * callback that will be executed once the `writeStream`is closed.
443
- * @since v0.9.4
444
- */
445
- close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
446
- /**
447
- * The number of bytes written so far. Does not include data that is still queued
448
- * for writing.
449
- * @since v0.4.7
450
- */
451
- bytesWritten: number;
452
- /**
453
- * The path to the file the stream is writing to as specified in the first
454
- * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a
455
- * `Buffer`.
456
- * @since v0.1.93
457
- */
458
- path: string | Buffer;
459
- /**
460
- * This property is `true` if the underlying file has not been opened yet,
461
- * i.e. before the `'ready'` event is emitted.
462
- * @since v11.2.0
463
- */
464
- pending: boolean;
465
- /**
466
- * events.EventEmitter
467
- * 1. open
468
- * 2. close
469
- * 3. ready
470
- */
471
- addListener(event: 'close', listener: () => void): this;
472
- addListener(event: 'drain', listener: () => void): this;
473
- addListener(event: 'error', listener: (err: Error) => void): this;
474
- addListener(event: 'finish', listener: () => void): this;
475
- addListener(event: 'open', listener: (fd: number) => void): this;
476
- addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
477
- addListener(event: 'ready', listener: () => void): this;
478
- addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
479
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
480
- on(event: 'close', listener: () => void): this;
481
- on(event: 'drain', listener: () => void): this;
482
- on(event: 'error', listener: (err: Error) => void): this;
483
- on(event: 'finish', listener: () => void): this;
484
- on(event: 'open', listener: (fd: number) => void): this;
485
- on(event: 'pipe', listener: (src: stream.Readable) => void): this;
486
- on(event: 'ready', listener: () => void): this;
487
- on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
488
- on(event: string | symbol, listener: (...args: any[]) => void): this;
489
- once(event: 'close', listener: () => void): this;
490
- once(event: 'drain', listener: () => void): this;
491
- once(event: 'error', listener: (err: Error) => void): this;
492
- once(event: 'finish', listener: () => void): this;
493
- once(event: 'open', listener: (fd: number) => void): this;
494
- once(event: 'pipe', listener: (src: stream.Readable) => void): this;
495
- once(event: 'ready', listener: () => void): this;
496
- once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
497
- once(event: string | symbol, listener: (...args: any[]) => void): this;
498
- prependListener(event: 'close', listener: () => void): this;
499
- prependListener(event: 'drain', listener: () => void): this;
500
- prependListener(event: 'error', listener: (err: Error) => void): this;
501
- prependListener(event: 'finish', listener: () => void): this;
502
- prependListener(event: 'open', listener: (fd: number) => void): this;
503
- prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
504
- prependListener(event: 'ready', listener: () => void): this;
505
- prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
506
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
507
- prependOnceListener(event: 'close', listener: () => void): this;
508
- prependOnceListener(event: 'drain', listener: () => void): this;
509
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
510
- prependOnceListener(event: 'finish', listener: () => void): this;
511
- prependOnceListener(event: 'open', listener: (fd: number) => void): this;
512
- prependOnceListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
513
- prependOnceListener(event: 'ready', listener: () => void): this;
514
- prependOnceListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
515
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
516
- }
517
- /**
518
- * Asynchronously rename file at `oldPath` to the pathname provided
519
- * as `newPath`. In the case that `newPath` already exists, it will
520
- * be overwritten. If there is a directory at `newPath`, an error will
521
- * be raised instead. No arguments other than a possible exception are
522
- * given to the completion callback.
523
- *
524
- * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).
525
- *
526
- * ```js
527
- * import { rename } from 'node:fs';
528
- *
529
- * rename('oldFile.txt', 'newFile.txt', (err) => {
530
- * if (err) throw err;
531
- * console.log('Rename complete!');
532
- * });
533
- * ```
534
- * @since v0.0.2
535
- */
536
- export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
537
- export namespace rename {
538
- /**
539
- * Asynchronous rename(2) - Change the name or location of a file or directory.
540
- * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
541
- * URL support is _experimental_.
542
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
543
- * URL support is _experimental_.
544
- */
545
- function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;
546
- }
547
- /**
548
- * Renames the file from `oldPath` to `newPath`. Returns `undefined`.
549
- *
550
- * See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details.
551
- * @since v0.1.21
552
- */
553
- export function renameSync(oldPath: PathLike, newPath: PathLike): void;
554
- /**
555
- * Truncates the file. No arguments other than a possible exception are
556
- * given to the completion callback. A file descriptor can also be passed as the
557
- * first argument. In this case, `fs.ftruncate()` is called.
558
- *
559
- * ```js
560
- * import { truncate } from 'node:fs';
561
- * // Assuming that 'path/file.txt' is a regular file.
562
- * truncate('path/file.txt', (err) => {
563
- * if (err) throw err;
564
- * console.log('path/file.txt was truncated');
565
- * });
566
- * ```
567
- *
568
- * Passing a file descriptor is deprecated and may result in an error being thrown
569
- * in the future.
570
- *
571
- * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.
572
- * @since v0.8.6
573
- * @param [len=0]
574
- */
575
- export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
576
- /**
577
- * Asynchronous truncate(2) - Truncate a file to a specified length.
578
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
579
- */
580
- export function truncate(path: PathLike, callback: NoParamCallback): void;
581
- export namespace truncate {
582
- /**
583
- * Asynchronous truncate(2) - Truncate a file to a specified length.
584
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
585
- * @param len If not specified, defaults to `0`.
586
- */
587
- function __promisify__(path: PathLike, len?: number | null): Promise<void>;
588
- }
589
- /**
590
- * Truncates the file. Returns `undefined`. A file descriptor can also be
591
- * passed as the first argument. In this case, `fs.ftruncateSync()` is called.
592
- *
593
- * Passing a file descriptor is deprecated and may result in an error being thrown
594
- * in the future.
595
- * @since v0.8.6
596
- * @param [len=0]
597
- */
598
- export function truncateSync(path: PathLike, len?: number | null): void;
599
- /**
600
- * Truncates the file descriptor. No arguments other than a possible exception are
601
- * given to the completion callback.
602
- *
603
- * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.
604
- *
605
- * If the file referred to by the file descriptor was larger than `len` bytes, only
606
- * the first `len` bytes will be retained in the file.
607
- *
608
- * For example, the following program retains only the first four bytes of the
609
- * file:
610
- *
611
- * ```js
612
- * import { open, close, ftruncate } from 'node:fs';
613
- *
614
- * function closeFd(fd) {
615
- * close(fd, (err) => {
616
- * if (err) throw err;
617
- * });
618
- * }
619
- *
620
- * open('temp.txt', 'r+', (err, fd) => {
621
- * if (err) throw err;
622
- *
623
- * try {
624
- * ftruncate(fd, 4, (err) => {
625
- * closeFd(fd);
626
- * if (err) throw err;
627
- * });
628
- * } catch (err) {
629
- * closeFd(fd);
630
- * if (err) throw err;
631
- * }
632
- * });
633
- * ```
634
- *
635
- * If the file previously was shorter than `len` bytes, it is extended, and the
636
- * extended part is filled with null bytes (`'\0'`):
637
- *
638
- * If `len` is negative then `0` will be used.
639
- * @since v0.8.6
640
- * @param [len=0]
641
- */
642
- export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
643
- /**
644
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
645
- * @param fd A file descriptor.
646
- */
647
- export function ftruncate(fd: number, callback: NoParamCallback): void;
648
- export namespace ftruncate {
649
- /**
650
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
651
- * @param fd A file descriptor.
652
- * @param len If not specified, defaults to `0`.
653
- */
654
- function __promisify__(fd: number, len?: number | null): Promise<void>;
655
- }
656
- /**
657
- * Truncates the file descriptor. Returns `undefined`.
658
- *
659
- * For detailed information, see the documentation of the asynchronous version of
660
- * this API: {@link ftruncate}.
661
- * @since v0.8.6
662
- * @param [len=0]
663
- */
664
- export function ftruncateSync(fd: number, len?: number | null): void;
665
- /**
666
- * Asynchronously changes owner and group of a file. No arguments other than a
667
- * possible exception are given to the completion callback.
668
- *
669
- * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
670
- * @since v0.1.97
671
- */
672
- export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
673
- export namespace chown {
674
- /**
675
- * Asynchronous chown(2) - Change ownership of a file.
676
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
677
- */
678
- function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
679
- }
680
- /**
681
- * Synchronously changes owner and group of a file. Returns `undefined`.
682
- * This is the synchronous version of {@link chown}.
683
- *
684
- * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
685
- * @since v0.1.97
686
- */
687
- export function chownSync(path: PathLike, uid: number, gid: number): void;
688
- /**
689
- * Sets the owner of the file. No arguments other than a possible exception are
690
- * given to the completion callback.
691
- *
692
- * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
693
- * @since v0.4.7
694
- */
695
- export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
696
- export namespace fchown {
697
- /**
698
- * Asynchronous fchown(2) - Change ownership of a file.
699
- * @param fd A file descriptor.
700
- */
701
- function __promisify__(fd: number, uid: number, gid: number): Promise<void>;
702
- }
703
- /**
704
- * Sets the owner of the file. Returns `undefined`.
705
- *
706
- * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
707
- * @since v0.4.7
708
- * @param uid The file's new owner's user id.
709
- * @param gid The file's new group's group id.
710
- */
711
- export function fchownSync(fd: number, uid: number, gid: number): void;
712
- /**
713
- * Set the owner of the symbolic link. No arguments other than a possible
714
- * exception are given to the completion callback.
715
- *
716
- * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.
717
- */
718
- export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
719
- export namespace lchown {
720
- /**
721
- * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
722
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
723
- */
724
- function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
725
- }
726
- /**
727
- * Set the owner for the path. Returns `undefined`.
728
- *
729
- * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details.
730
- * @param uid The file's new owner's user id.
731
- * @param gid The file's new group's group id.
732
- */
733
- export function lchownSync(path: PathLike, uid: number, gid: number): void;
734
- /**
735
- * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic
736
- * link, then the link is not dereferenced: instead, the timestamps of the
737
- * symbolic link itself are changed.
738
- *
739
- * No arguments other than a possible exception are given to the completion
740
- * callback.
741
- * @since v14.5.0, v12.19.0
742
- */
743
- export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
744
- export namespace lutimes {
745
- /**
746
- * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`,
747
- * with the difference that if the path refers to a symbolic link, then the link is not
748
- * dereferenced: instead, the timestamps of the symbolic link itself are changed.
749
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
750
- * @param atime The last access time. If a string is provided, it will be coerced to number.
751
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
752
- */
753
- function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
754
- }
755
- /**
756
- * Change the file system timestamps of the symbolic link referenced by `path`.
757
- * Returns `undefined`, or throws an exception when parameters are incorrect or
758
- * the operation fails. This is the synchronous version of {@link lutimes}.
759
- * @since v14.5.0, v12.19.0
760
- */
761
- export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
762
- /**
763
- * Asynchronously changes the permissions of a file. No arguments other than a
764
- * possible exception are given to the completion callback.
765
- *
766
- * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
767
- *
768
- * ```js
769
- * import { chmod } from 'node:fs';
770
- *
771
- * chmod('my_file.txt', 0o775, (err) => {
772
- * if (err) throw err;
773
- * console.log('The permissions for file "my_file.txt" have been changed!');
774
- * });
775
- * ```
776
- * @since v0.1.30
777
- */
778
- export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
779
- export namespace chmod {
780
- /**
781
- * Asynchronous chmod(2) - Change permissions of a file.
782
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
783
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
784
- */
785
- function __promisify__(path: PathLike, mode: Mode): Promise<void>;
786
- }
787
- /**
788
- * For detailed information, see the documentation of the asynchronous version of
789
- * this API: {@link chmod}.
790
- *
791
- * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
792
- * @since v0.6.7
793
- */
794
- export function chmodSync(path: PathLike, mode: Mode): void;
795
- /**
796
- * Sets the permissions on the file. No arguments other than a possible exception
797
- * are given to the completion callback.
798
- *
799
- * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
800
- * @since v0.4.7
801
- */
802
- export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
803
- export namespace fchmod {
804
- /**
805
- * Asynchronous fchmod(2) - Change permissions of a file.
806
- * @param fd A file descriptor.
807
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
808
- */
809
- function __promisify__(fd: number, mode: Mode): Promise<void>;
810
- }
811
- /**
812
- * Sets the permissions on the file. Returns `undefined`.
813
- *
814
- * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
815
- * @since v0.4.7
816
- */
817
- export function fchmodSync(fd: number, mode: Mode): void;
818
- /**
819
- * Changes the permissions on a symbolic link. No arguments other than a possible
820
- * exception are given to the completion callback.
821
- *
822
- * This method is only implemented on macOS.
823
- *
824
- * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
825
- * @deprecated Since v0.4.7
826
- */
827
- export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
828
- /** @deprecated */
829
- export namespace lchmod {
830
- /**
831
- * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
832
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
833
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
834
- */
835
- function __promisify__(path: PathLike, mode: Mode): Promise<void>;
836
- }
837
- /**
838
- * Changes the permissions on a symbolic link. Returns `undefined`.
839
- *
840
- * This method is only implemented on macOS.
841
- *
842
- * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
843
- * @deprecated Since v0.4.7
844
- */
845
- export function lchmodSync(path: PathLike, mode: Mode): void;
846
- /**
847
- * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.
848
- *
849
- * In case of an error, the `err.code` will be one of `Common System Errors`.
850
- *
851
- * {@link stat} follows symbolic links. Use {@link lstat} to look at the
852
- * links themselves.
853
- *
854
- * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.
855
- * Instead, user code should open/read/write the file directly and handle the
856
- * error raised if the file is not available.
857
- *
858
- * To check if a file exists without manipulating it afterwards, {@link access} is recommended.
859
- *
860
- * For example, given the following directory structure:
861
- *
862
- * ```text
863
- * - txtDir
864
- * -- file.txt
865
- * - app.js
866
- * ```
867
- *
868
- * The next program will check for the stats of the given paths:
869
- *
870
- * ```js
871
- * import { stat } from 'node:fs';
872
- *
873
- * const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
874
- *
875
- * for (let i = 0; i < pathsToCheck.length; i++) {
876
- * stat(pathsToCheck[i], (err, stats) => {
877
- * console.log(stats.isDirectory());
878
- * console.log(stats);
879
- * });
880
- * }
881
- * ```
882
- *
883
- * The resulting output will resemble:
884
- *
885
- * ```console
886
- * true
887
- * Stats {
888
- * dev: 16777220,
889
- * mode: 16877,
890
- * nlink: 3,
891
- * uid: 501,
892
- * gid: 20,
893
- * rdev: 0,
894
- * blksize: 4096,
895
- * ino: 14214262,
896
- * size: 96,
897
- * blocks: 0,
898
- * atimeMs: 1561174653071.963,
899
- * mtimeMs: 1561174614583.3518,
900
- * ctimeMs: 1561174626623.5366,
901
- * birthtimeMs: 1561174126937.2893,
902
- * atime: 2019-06-22T03:37:33.072Z,
903
- * mtime: 2019-06-22T03:36:54.583Z,
904
- * ctime: 2019-06-22T03:37:06.624Z,
905
- * birthtime: 2019-06-22T03:28:46.937Z
906
- * }
907
- * false
908
- * Stats {
909
- * dev: 16777220,
910
- * mode: 33188,
911
- * nlink: 1,
912
- * uid: 501,
913
- * gid: 20,
914
- * rdev: 0,
915
- * blksize: 4096,
916
- * ino: 14214074,
917
- * size: 8,
918
- * blocks: 8,
919
- * atimeMs: 1561174616618.8555,
920
- * mtimeMs: 1561174614584,
921
- * ctimeMs: 1561174614583.8145,
922
- * birthtimeMs: 1561174007710.7478,
923
- * atime: 2019-06-22T03:36:56.619Z,
924
- * mtime: 2019-06-22T03:36:54.584Z,
925
- * ctime: 2019-06-22T03:36:54.584Z,
926
- * birthtime: 2019-06-22T03:26:47.711Z
927
- * }
928
- * ```
929
- * @since v0.0.2
930
- */
931
- export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
932
- export function stat(
933
- path: PathLike,
934
- options:
935
- | (StatOptions & {
936
- bigint?: false | undefined;
937
- })
938
- | undefined,
939
- callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
940
- ): void;
941
- export function stat(
942
- path: PathLike,
943
- options: StatOptions & {
944
- bigint: true;
945
- },
946
- callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
947
- ): void;
948
- export function stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
949
- export namespace stat {
950
- /**
951
- * Asynchronous stat(2) - Get file status.
952
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
953
- */
954
- function __promisify__(
955
- path: PathLike,
956
- options?: StatOptions & {
957
- bigint?: false | undefined;
958
- }
959
- ): Promise<Stats>;
960
- function __promisify__(
961
- path: PathLike,
962
- options: StatOptions & {
963
- bigint: true;
964
- }
965
- ): Promise<BigIntStats>;
966
- function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
967
- }
968
- export interface StatSyncFn extends Function {
969
- (path: PathLike, options?: undefined): Stats;
970
- (
971
- path: PathLike,
972
- options?: StatSyncOptions & {
973
- bigint?: false | undefined;
974
- throwIfNoEntry: false;
975
- }
976
- ): Stats | undefined;
977
- (
978
- path: PathLike,
979
- options: StatSyncOptions & {
980
- bigint: true;
981
- throwIfNoEntry: false;
982
- }
983
- ): BigIntStats | undefined;
984
- (
985
- path: PathLike,
986
- options?: StatSyncOptions & {
987
- bigint?: false | undefined;
988
- }
989
- ): Stats;
990
- (
991
- path: PathLike,
992
- options: StatSyncOptions & {
993
- bigint: true;
994
- }
995
- ): BigIntStats;
996
- (
997
- path: PathLike,
998
- options: StatSyncOptions & {
999
- bigint: boolean;
1000
- throwIfNoEntry?: false | undefined;
1001
- }
1002
- ): Stats | BigIntStats;
1003
- (path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined;
1004
- }
1005
- /**
1006
- * Synchronous stat(2) - Get file status.
1007
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1008
- */
1009
- export const statSync: StatSyncFn;
1010
- /**
1011
- * Invokes the callback with the `fs.Stats` for the file descriptor.
1012
- *
1013
- * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
1014
- * @since v0.1.95
1015
- */
1016
- export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
1017
- export function fstat(
1018
- fd: number,
1019
- options:
1020
- | (StatOptions & {
1021
- bigint?: false | undefined;
1022
- })
1023
- | undefined,
1024
- callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
1025
- ): void;
1026
- export function fstat(
1027
- fd: number,
1028
- options: StatOptions & {
1029
- bigint: true;
1030
- },
1031
- callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
1032
- ): void;
1033
- export function fstat(fd: number, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
1034
- export namespace fstat {
1035
- /**
1036
- * Asynchronous fstat(2) - Get file status.
1037
- * @param fd A file descriptor.
1038
- */
1039
- function __promisify__(
1040
- fd: number,
1041
- options?: StatOptions & {
1042
- bigint?: false | undefined;
1043
- }
1044
- ): Promise<Stats>;
1045
- function __promisify__(
1046
- fd: number,
1047
- options: StatOptions & {
1048
- bigint: true;
1049
- }
1050
- ): Promise<BigIntStats>;
1051
- function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
1052
- }
1053
- /**
1054
- * Retrieves the `fs.Stats` for the file descriptor.
1055
- *
1056
- * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
1057
- * @since v0.1.95
1058
- */
1059
- export function fstatSync(
1060
- fd: number,
1061
- options?: StatOptions & {
1062
- bigint?: false | undefined;
1063
- }
1064
- ): Stats;
1065
- export function fstatSync(
1066
- fd: number,
1067
- options: StatOptions & {
1068
- bigint: true;
1069
- }
1070
- ): BigIntStats;
1071
- export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
1072
- /**
1073
- * Retrieves the `fs.Stats` for the symbolic link referred to by the path.
1074
- * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
1075
- * link, then the link itself is stat-ed, not the file that it refers to.
1076
- *
1077
- * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.
1078
- * @since v0.1.30
1079
- */
1080
- export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
1081
- export function lstat(
1082
- path: PathLike,
1083
- options:
1084
- | (StatOptions & {
1085
- bigint?: false | undefined;
1086
- })
1087
- | undefined,
1088
- callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void
1089
- ): void;
1090
- export function lstat(
1091
- path: PathLike,
1092
- options: StatOptions & {
1093
- bigint: true;
1094
- },
1095
- callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void
1096
- ): void;
1097
- export function lstat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
1098
- export namespace lstat {
1099
- /**
1100
- * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
1101
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1102
- */
1103
- function __promisify__(
1104
- path: PathLike,
1105
- options?: StatOptions & {
1106
- bigint?: false | undefined;
1107
- }
1108
- ): Promise<Stats>;
1109
- function __promisify__(
1110
- path: PathLike,
1111
- options: StatOptions & {
1112
- bigint: true;
1113
- }
1114
- ): Promise<BigIntStats>;
1115
- function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
1116
- }
1117
- /**
1118
- * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1119
- * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.
1120
- *
1121
- * In case of an error, the `err.code` will be one of `Common System Errors`.
1122
- * @since v19.6.0, v18.15.0
1123
- * @param path A path to an existing file or directory on the file system to be queried.
1124
- */
1125
- export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void;
1126
- export function statfs(
1127
- path: PathLike,
1128
- options:
1129
- | (StatFsOptions & {
1130
- bigint?: false | undefined;
1131
- })
1132
- | undefined,
1133
- callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void
1134
- ): void;
1135
- export function statfs(
1136
- path: PathLike,
1137
- options: StatFsOptions & {
1138
- bigint: true;
1139
- },
1140
- callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void
1141
- ): void;
1142
- export function statfs(path: PathLike, options: StatFsOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void): void;
1143
- export namespace statfs {
1144
- /**
1145
- * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an <fs.StatFs> object.
1146
- * @param path A path to an existing file or directory on the file system to be queried.
1147
- */
1148
- function __promisify__(
1149
- path: PathLike,
1150
- options?: StatFsOptions & {
1151
- bigint?: false | undefined;
1152
- }
1153
- ): Promise<StatsFs>;
1154
- function __promisify__(
1155
- path: PathLike,
1156
- options: StatFsOptions & {
1157
- bigint: true;
1158
- }
1159
- ): Promise<BigIntStatsFs>;
1160
- function __promisify__(path: PathLike, options?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
1161
- }
1162
- /**
1163
- * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1164
- * contains `path`.
1165
- *
1166
- * In case of an error, the `err.code` will be one of `Common System Errors`.
1167
- * @since v19.6.0, v18.15.0
1168
- * @param path A path to an existing file or directory on the file system to be queried.
1169
- */
1170
- export function statfsSync(
1171
- path: PathLike,
1172
- options?: StatFsOptions & {
1173
- bigint?: false | undefined;
1174
- }
1175
- ): StatsFs;
1176
- export function statfsSync(
1177
- path: PathLike,
1178
- options: StatFsOptions & {
1179
- bigint: true;
1180
- }
1181
- ): BigIntStatsFs;
1182
- export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs;
1183
- /**
1184
- * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
1185
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1186
- */
1187
- export const lstatSync: StatSyncFn;
1188
- /**
1189
- * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than
1190
- * a possible
1191
- * exception are given to the completion callback.
1192
- * @since v0.1.31
1193
- */
1194
- export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
1195
- export namespace link {
1196
- /**
1197
- * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
1198
- * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
1199
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
1200
- */
1201
- function __promisify__(existingPath: PathLike, newPath: PathLike): Promise<void>;
1202
- }
1203
- /**
1204
- * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. Returns `undefined`.
1205
- * @since v0.1.31
1206
- */
1207
- export function linkSync(existingPath: PathLike, newPath: PathLike): void;
1208
- /**
1209
- * Creates the link called `path` pointing to `target`. No arguments other than a
1210
- * possible exception are given to the completion callback.
1211
- *
1212
- * See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details.
1213
- *
1214
- * The `type` argument is only available on Windows and ignored on other platforms.
1215
- * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
1216
- * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
1217
- * If the `target` does not exist, `'file'` will be used. Windows junction points
1218
- * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path.
1219
- *
1220
- * Relative targets are relative to the link's parent directory.
1221
- *
1222
- * ```js
1223
- * import { symlink } from 'node:fs';
1224
- *
1225
- * symlink('./mew', './mewtwo', callback);
1226
- * ```
1227
- *
1228
- * The above example creates a symbolic link `mewtwo` which points to `mew` in the
1229
- * same directory:
1230
- *
1231
- * ```bash
1232
- * $ tree .
1233
- * .
1234
- * ├── mew
1235
- * └── mewtwo -> ./mew
1236
- * ```
1237
- * @since v0.1.31
1238
- * @param [type='null']
1239
- */
1240
- export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
1241
- /**
1242
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
1243
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
1244
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
1245
- */
1246
- export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
1247
- export namespace symlink {
1248
- /**
1249
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
1250
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
1251
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
1252
- * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
1253
- * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
1254
- */
1255
- function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
1256
- type Type = 'dir' | 'file' | 'junction';
1257
- }
1258
- /**
1259
- * Returns `undefined`.
1260
- *
1261
- * For detailed information, see the documentation of the asynchronous version of
1262
- * this API: {@link symlink}.
1263
- * @since v0.1.31
1264
- * @param [type='null']
1265
- */
1266
- export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
1267
- /**
1268
- * Reads the contents of the symbolic link referred to by `path`. The callback gets
1269
- * two arguments `(err, linkString)`.
1270
- *
1271
- * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
1272
- *
1273
- * The optional `options` argument can be a string specifying an encoding, or an
1274
- * object with an `encoding` property specifying the character encoding to use for
1275
- * the link path passed to the callback. If the `encoding` is set to `'buffer'`,
1276
- * the link path returned will be passed as a `Buffer` object.
1277
- * @since v0.1.31
1278
- */
1279
- export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
1280
- /**
1281
- * Asynchronous readlink(2) - read value of a symbolic link.
1282
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1283
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1284
- */
1285
- export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
1286
- /**
1287
- * Asynchronous readlink(2) - read value of a symbolic link.
1288
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1289
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1290
- */
1291
- export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
1292
- /**
1293
- * Asynchronous readlink(2) - read value of a symbolic link.
1294
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1295
- */
1296
- export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
1297
- export namespace readlink {
1298
- /**
1299
- * Asynchronous readlink(2) - read value of a symbolic link.
1300
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1301
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1302
- */
1303
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
1304
- /**
1305
- * Asynchronous readlink(2) - read value of a symbolic link.
1306
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1307
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1308
- */
1309
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1310
- /**
1311
- * Asynchronous readlink(2) - read value of a symbolic link.
1312
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1313
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1314
- */
1315
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1316
- }
1317
- /**
1318
- * Returns the symbolic link's string value.
1319
- *
1320
- * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
1321
- *
1322
- * The optional `options` argument can be a string specifying an encoding, or an
1323
- * object with an `encoding` property specifying the character encoding to use for
1324
- * the link path returned. If the `encoding` is set to `'buffer'`,
1325
- * the link path returned will be passed as a `Buffer` object.
1326
- * @since v0.1.31
1327
- */
1328
- export function readlinkSync(path: PathLike, options?: EncodingOption): string;
1329
- /**
1330
- * Synchronous readlink(2) - read value of a symbolic link.
1331
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1332
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1333
- */
1334
- export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
1335
- /**
1336
- * Synchronous readlink(2) - read value of a symbolic link.
1337
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1338
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1339
- */
1340
- export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
1341
- /**
1342
- * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
1343
- * symbolic links.
1344
- *
1345
- * A canonical pathname is not necessarily unique. Hard links and bind mounts can
1346
- * expose a file system entity through many pathnames.
1347
- *
1348
- * This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions:
1349
- *
1350
- * 1. No case conversion is performed on case-insensitive file systems.
1351
- * 2. The maximum number of symbolic links is platform-independent and generally
1352
- * (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.
1353
- *
1354
- * The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths.
1355
- *
1356
- * Only paths that can be converted to UTF8 strings are supported.
1357
- *
1358
- * The optional `options` argument can be a string specifying an encoding, or an
1359
- * object with an `encoding` property specifying the character encoding to use for
1360
- * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1361
- * the path returned will be passed as a `Buffer` object.
1362
- *
1363
- * If `path` resolves to a socket or a pipe, the function will return a system
1364
- * dependent name for that object.
1365
- * @since v0.1.31
1366
- */
1367
- export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
1368
- /**
1369
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1370
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1371
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1372
- */
1373
- export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
1374
- /**
1375
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1376
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1377
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1378
- */
1379
- export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
1380
- /**
1381
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1382
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1383
- */
1384
- export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
1385
- export namespace realpath {
1386
- /**
1387
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1388
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1389
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1390
- */
1391
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
1392
- /**
1393
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1394
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1395
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1396
- */
1397
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1398
- /**
1399
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1400
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1401
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1402
- */
1403
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1404
- /**
1405
- * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).
1406
- *
1407
- * The `callback` gets two arguments `(err, resolvedPath)`.
1408
- *
1409
- * Only paths that can be converted to UTF8 strings are supported.
1410
- *
1411
- * The optional `options` argument can be a string specifying an encoding, or an
1412
- * object with an `encoding` property specifying the character encoding to use for
1413
- * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1414
- * the path returned will be passed as a `Buffer` object.
1415
- *
1416
- * On Linux, when Node.js is linked against musl libc, the procfs file system must
1417
- * be mounted on `/proc` in order for this function to work. Glibc does not have
1418
- * this restriction.
1419
- * @since v9.2.0
1420
- */
1421
- function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
1422
- function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
1423
- function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
1424
- function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
1425
- }
1426
- /**
1427
- * Returns the resolved pathname.
1428
- *
1429
- * For detailed information, see the documentation of the asynchronous version of
1430
- * this API: {@link realpath}.
1431
- * @since v0.1.31
1432
- */
1433
- export function realpathSync(path: PathLike, options?: EncodingOption): string;
1434
- /**
1435
- * Synchronous realpath(3) - return the canonicalized absolute pathname.
1436
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1437
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1438
- */
1439
- export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
1440
- /**
1441
- * Synchronous realpath(3) - return the canonicalized absolute pathname.
1442
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1443
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1444
- */
1445
- export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
1446
- export namespace realpathSync {
1447
- function native(path: PathLike, options?: EncodingOption): string;
1448
- function native(path: PathLike, options: BufferEncodingOption): Buffer;
1449
- function native(path: PathLike, options?: EncodingOption): string | Buffer;
1450
- }
1451
- /**
1452
- * Asynchronously removes a file or symbolic link. No arguments other than a
1453
- * possible exception are given to the completion callback.
1454
- *
1455
- * ```js
1456
- * import { unlink } from 'node:fs';
1457
- * // Assuming that 'path/file.txt' is a regular file.
1458
- * unlink('path/file.txt', (err) => {
1459
- * if (err) throw err;
1460
- * console.log('path/file.txt was deleted');
1461
- * });
1462
- * ```
1463
- *
1464
- * `fs.unlink()` will not work on a directory, empty or otherwise. To remove a
1465
- * directory, use {@link rmdir}.
1466
- *
1467
- * See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details.
1468
- * @since v0.0.2
1469
- */
1470
- export function unlink(path: PathLike, callback: NoParamCallback): void;
1471
- export namespace unlink {
1472
- /**
1473
- * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
1474
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1475
- */
1476
- function __promisify__(path: PathLike): Promise<void>;
1477
- }
1478
- /**
1479
- * Synchronous [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html). Returns `undefined`.
1480
- * @since v0.1.21
1481
- */
1482
- export function unlinkSync(path: PathLike): void;
1483
- export interface RmDirOptions {
1484
- /**
1485
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1486
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
1487
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
1488
- * number of retries. This option is ignored if the `recursive` option is not
1489
- * `true`.
1490
- * @default 0
1491
- */
1492
- maxRetries?: number | undefined;
1493
- /**
1494
- * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
1495
- * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
1496
- * Use `fs.rm(path, { recursive: true, force: true })` instead.
1497
- *
1498
- * If `true`, perform a recursive directory removal. In
1499
- * recursive mode, operations are retried on failure.
1500
- * @default false
1501
- */
1502
- recursive?: boolean | undefined;
1503
- /**
1504
- * The amount of time in milliseconds to wait between retries.
1505
- * This option is ignored if the `recursive` option is not `true`.
1506
- * @default 100
1507
- */
1508
- retryDelay?: number | undefined;
1509
- }
1510
- /**
1511
- * Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given
1512
- * to the completion callback.
1513
- *
1514
- * Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on
1515
- * Windows and an `ENOTDIR` error on POSIX.
1516
- *
1517
- * To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`.
1518
- * @since v0.0.2
1519
- */
1520
- export function rmdir(path: PathLike, callback: NoParamCallback): void;
1521
- export function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
1522
- export namespace rmdir {
1523
- /**
1524
- * Asynchronous rmdir(2) - delete a directory.
1525
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1526
- */
1527
- function __promisify__(path: PathLike, options?: RmDirOptions): Promise<void>;
1528
- }
1529
- /**
1530
- * Synchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). Returns `undefined`.
1531
- *
1532
- * Using `fs.rmdirSync()` on a file (not a directory) results in an `ENOENT` error
1533
- * on Windows and an `ENOTDIR` error on POSIX.
1534
- *
1535
- * To get a behavior similar to the `rm -rf` Unix command, use {@link rmSync} with options `{ recursive: true, force: true }`.
1536
- * @since v0.1.21
1537
- */
1538
- export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
1539
- export interface RmOptions {
1540
- /**
1541
- * When `true`, exceptions will be ignored if `path` does not exist.
1542
- * @default false
1543
- */
1544
- force?: boolean | undefined;
1545
- /**
1546
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
1547
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
1548
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
1549
- * number of retries. This option is ignored if the `recursive` option is not
1550
- * `true`.
1551
- * @default 0
1552
- */
1553
- maxRetries?: number | undefined;
1554
- /**
1555
- * If `true`, perform a recursive directory removal. In
1556
- * recursive mode, operations are retried on failure.
1557
- * @default false
1558
- */
1559
- recursive?: boolean | undefined;
1560
- /**
1561
- * The amount of time in milliseconds to wait between retries.
1562
- * This option is ignored if the `recursive` option is not `true`.
1563
- * @default 100
1564
- */
1565
- retryDelay?: number | undefined;
1566
- }
1567
- /**
1568
- * Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
1569
- * completion callback.
1570
- * @since v14.14.0
1571
- */
1572
- export function rm(path: PathLike, callback: NoParamCallback): void;
1573
- export function rm(path: PathLike, options: RmOptions, callback: NoParamCallback): void;
1574
- export namespace rm {
1575
- /**
1576
- * Asynchronously removes files and directories (modeled on the standard POSIX `rm` utility).
1577
- */
1578
- function __promisify__(path: PathLike, options?: RmOptions): Promise<void>;
1579
- }
1580
- /**
1581
- * Synchronously removes files and directories (modeled on the standard POSIX `rm`utility). Returns `undefined`.
1582
- * @since v14.14.0
1583
- */
1584
- export function rmSync(path: PathLike, options?: RmOptions): void;
1585
- export interface MakeDirectoryOptions {
1586
- /**
1587
- * Indicates whether parent folders should be created.
1588
- * If a folder was created, the path to the first created folder will be returned.
1589
- * @default false
1590
- */
1591
- recursive?: boolean | undefined;
1592
- /**
1593
- * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
1594
- * @default 0o777
1595
- */
1596
- mode?: Mode | undefined;
1597
- }
1598
- /**
1599
- * Asynchronously creates a directory.
1600
- *
1601
- * The callback is given a possible exception and, if `recursive` is `true`, the
1602
- * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
1603
- * created.
1604
- *
1605
- * The optional `options` argument can be an integer specifying `mode` (permission
1606
- * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that
1607
- * exists results in an error only
1608
- * when `recursive` is false.
1609
- *
1610
- * ```js
1611
- * import { mkdir } from 'node:fs';
1612
- *
1613
- * // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.
1614
- * mkdir('/tmp/a/apple', { recursive: true }, (err) => {
1615
- * if (err) throw err;
1616
- * });
1617
- * ```
1618
- *
1619
- * On Windows, using `fs.mkdir()` on the root directory even with recursion will
1620
- * result in an error:
1621
- *
1622
- * ```js
1623
- * import { mkdir } from 'node:fs';
1624
- *
1625
- * mkdir('/', { recursive: true }, (err) => {
1626
- * // => [Error: EPERM: operation not permitted, mkdir 'C:\']
1627
- * });
1628
- * ```
1629
- *
1630
- * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
1631
- * @since v0.1.8
1632
- */
1633
- export function mkdir(
1634
- path: PathLike,
1635
- options: MakeDirectoryOptions & {
1636
- recursive: true;
1637
- },
1638
- callback: (err: NodeJS.ErrnoException | null, path?: string) => void
1639
- ): void;
1640
- /**
1641
- * Asynchronous mkdir(2) - create a directory.
1642
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1643
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1644
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1645
- */
1646
- export function mkdir(
1647
- path: PathLike,
1648
- options:
1649
- | Mode
1650
- | (MakeDirectoryOptions & {
1651
- recursive?: false | undefined;
1652
- })
1653
- | null
1654
- | undefined,
1655
- callback: NoParamCallback
1656
- ): void;
1657
- /**
1658
- * Asynchronous mkdir(2) - create a directory.
1659
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1660
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1661
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1662
- */
1663
- export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path?: string) => void): void;
1664
- /**
1665
- * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
1666
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1667
- */
1668
- export function mkdir(path: PathLike, callback: NoParamCallback): void;
1669
- export namespace mkdir {
1670
- /**
1671
- * Asynchronous mkdir(2) - create a directory.
1672
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1673
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1674
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1675
- */
1676
- function __promisify__(
1677
- path: PathLike,
1678
- options: MakeDirectoryOptions & {
1679
- recursive: true;
1680
- }
1681
- ): Promise<string | undefined>;
1682
- /**
1683
- * Asynchronous mkdir(2) - create a directory.
1684
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1685
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1686
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1687
- */
1688
- function __promisify__(
1689
- path: PathLike,
1690
- options?:
1691
- | Mode
1692
- | (MakeDirectoryOptions & {
1693
- recursive?: false | undefined;
1694
- })
1695
- | null
1696
- ): Promise<void>;
1697
- /**
1698
- * Asynchronous mkdir(2) - create a directory.
1699
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1700
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1701
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1702
- */
1703
- function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
1704
- }
1705
- /**
1706
- * Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created.
1707
- * This is the synchronous version of {@link mkdir}.
1708
- *
1709
- * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
1710
- * @since v0.1.21
1711
- */
1712
- export function mkdirSync(
1713
- path: PathLike,
1714
- options: MakeDirectoryOptions & {
1715
- recursive: true;
1716
- }
1717
- ): string | undefined;
1718
- /**
1719
- * Synchronous mkdir(2) - create a directory.
1720
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1721
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1722
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1723
- */
1724
- export function mkdirSync(
1725
- path: PathLike,
1726
- options?:
1727
- | Mode
1728
- | (MakeDirectoryOptions & {
1729
- recursive?: false | undefined;
1730
- })
1731
- | null
1732
- ): void;
1733
- /**
1734
- * Synchronous mkdir(2) - create a directory.
1735
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1736
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
1737
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
1738
- */
1739
- export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
1740
- /**
1741
- * Creates a unique temporary directory.
1742
- *
1743
- * Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform
1744
- * inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
1745
- * notably the BSDs, can return more than six random characters, and replace
1746
- * trailing `X` characters in `prefix` with random characters.
1747
- *
1748
- * The created directory path is passed as a string to the callback's second
1749
- * parameter.
1750
- *
1751
- * The optional `options` argument can be a string specifying an encoding, or an
1752
- * object with an `encoding` property specifying the character encoding to use.
1753
- *
1754
- * ```js
1755
- * import { mkdtemp } from 'node:fs';
1756
- * import { join } from 'node:path';
1757
- * import { tmpdir } from 'node:os';
1758
- *
1759
- * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {
1760
- * if (err) throw err;
1761
- * console.log(directory);
1762
- * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
1763
- * });
1764
- * ```
1765
- *
1766
- * The `fs.mkdtemp()` method will append the six randomly selected characters
1767
- * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
1768
- * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
1769
- * (`require('node:path').sep`).
1770
- *
1771
- * ```js
1772
- * import { tmpdir } from 'node:os';
1773
- * import { mkdtemp } from 'node:fs';
1774
- *
1775
- * // The parent directory for the new temporary directory
1776
- * const tmpDir = tmpdir();
1777
- *
1778
- * // This method is *INCORRECT*:
1779
- * mkdtemp(tmpDir, (err, directory) => {
1780
- * if (err) throw err;
1781
- * console.log(directory);
1782
- * // Will print something similar to `/tmpabc123`.
1783
- * // A new temporary directory is created at the file system root
1784
- * // rather than *within* the /tmp directory.
1785
- * });
1786
- *
1787
- * // This method is *CORRECT*:
1788
- * import { sep } from 'node:path';
1789
- * mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
1790
- * if (err) throw err;
1791
- * console.log(directory);
1792
- * // Will print something similar to `/tmp/abc123`.
1793
- * // A new temporary directory is created within
1794
- * // the /tmp directory.
1795
- * });
1796
- * ```
1797
- * @since v5.10.0
1798
- */
1799
- export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
1800
- /**
1801
- * Asynchronously creates a unique temporary directory.
1802
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1803
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1804
- */
1805
- export function mkdtemp(
1806
- prefix: string,
1807
- options:
1808
- | 'buffer'
1809
- | {
1810
- encoding: 'buffer';
1811
- },
1812
- callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void
1813
- ): void;
1814
- /**
1815
- * Asynchronously creates a unique temporary directory.
1816
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1817
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1818
- */
1819
- export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
1820
- /**
1821
- * Asynchronously creates a unique temporary directory.
1822
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1823
- */
1824
- export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
1825
- export namespace mkdtemp {
1826
- /**
1827
- * Asynchronously creates a unique temporary directory.
1828
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1829
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1830
- */
1831
- function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
1832
- /**
1833
- * Asynchronously creates a unique temporary directory.
1834
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1835
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1836
- */
1837
- function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
1838
- /**
1839
- * Asynchronously creates a unique temporary directory.
1840
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1841
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1842
- */
1843
- function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
1844
- }
1845
- /**
1846
- * Returns the created directory path.
1847
- *
1848
- * For detailed information, see the documentation of the asynchronous version of
1849
- * this API: {@link mkdtemp}.
1850
- *
1851
- * The optional `options` argument can be a string specifying an encoding, or an
1852
- * object with an `encoding` property specifying the character encoding to use.
1853
- * @since v5.10.0
1854
- */
1855
- export function mkdtempSync(prefix: string, options?: EncodingOption): string;
1856
- /**
1857
- * Synchronously creates a unique temporary directory.
1858
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1859
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1860
- */
1861
- export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
1862
- /**
1863
- * Synchronously creates a unique temporary directory.
1864
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1865
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1866
- */
1867
- export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
1868
- /**
1869
- * Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`.
1870
- *
1871
- * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
1872
- *
1873
- * The optional `options` argument can be a string specifying an encoding, or an
1874
- * object with an `encoding` property specifying the character encoding to use for
1875
- * the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
1876
- * the filenames returned will be passed as `Buffer` objects.
1877
- *
1878
- * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects.
1879
- * @since v0.1.8
1880
- */
1881
- export function readdir(
1882
- path: PathLike,
1883
- options:
1884
- | {
1885
- encoding: BufferEncoding | null;
1886
- withFileTypes?: false | undefined;
1887
- recursive?: boolean | undefined;
1888
- }
1889
- | BufferEncoding
1890
- | undefined
1891
- | null,
1892
- callback: (err: NodeJS.ErrnoException | null, files: string[]) => void
1893
- ): void;
1894
- /**
1895
- * Asynchronous readdir(3) - read a directory.
1896
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1897
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1898
- */
1899
- export function readdir(
1900
- path: PathLike,
1901
- options:
1902
- | {
1903
- encoding: 'buffer';
1904
- withFileTypes?: false | undefined;
1905
- recursive?: boolean | undefined;
1906
- }
1907
- | 'buffer',
1908
- callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void
1909
- ): void;
1910
- /**
1911
- * Asynchronous readdir(3) - read a directory.
1912
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1913
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1914
- */
1915
- export function readdir(
1916
- path: PathLike,
1917
- options:
1918
- | (ObjectEncodingOptions & {
1919
- withFileTypes?: false | undefined;
1920
- recursive?: boolean | undefined;
1921
- })
1922
- | BufferEncoding
1923
- | undefined
1924
- | null,
1925
- callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void
1926
- ): void;
1927
- /**
1928
- * Asynchronous readdir(3) - read a directory.
1929
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1930
- */
1931
- export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
1932
- /**
1933
- * Asynchronous readdir(3) - read a directory.
1934
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1935
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1936
- */
1937
- export function readdir(
1938
- path: PathLike,
1939
- options: ObjectEncodingOptions & {
1940
- withFileTypes: true;
1941
- recursive?: boolean | undefined;
1942
- },
1943
- callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void
1944
- ): void;
1945
- export namespace readdir {
1946
- /**
1947
- * Asynchronous readdir(3) - read a directory.
1948
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1949
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1950
- */
1951
- function __promisify__(
1952
- path: PathLike,
1953
- options?:
1954
- | {
1955
- encoding: BufferEncoding | null;
1956
- withFileTypes?: false | undefined;
1957
- recursive?: boolean | undefined;
1958
- }
1959
- | BufferEncoding
1960
- | null
1961
- ): Promise<string[]>;
1962
- /**
1963
- * Asynchronous readdir(3) - read a directory.
1964
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1965
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1966
- */
1967
- function __promisify__(
1968
- path: PathLike,
1969
- options:
1970
- | 'buffer'
1971
- | {
1972
- encoding: 'buffer';
1973
- withFileTypes?: false | undefined;
1974
- recursive?: boolean | undefined;
1975
- }
1976
- ): Promise<Buffer[]>;
1977
- /**
1978
- * Asynchronous readdir(3) - read a directory.
1979
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1980
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1981
- */
1982
- function __promisify__(
1983
- path: PathLike,
1984
- options?:
1985
- | (ObjectEncodingOptions & {
1986
- withFileTypes?: false | undefined;
1987
- recursive?: boolean | undefined;
1988
- })
1989
- | BufferEncoding
1990
- | null
1991
- ): Promise<string[] | Buffer[]>;
1992
- /**
1993
- * Asynchronous readdir(3) - read a directory.
1994
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1995
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
1996
- */
1997
- function __promisify__(
1998
- path: PathLike,
1999
- options: ObjectEncodingOptions & {
2000
- withFileTypes: true;
2001
- recursive?: boolean | undefined;
2002
- }
2003
- ): Promise<Dirent[]>;
2004
- }
2005
- /**
2006
- * Reads the contents of the directory.
2007
- *
2008
- * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
2009
- *
2010
- * The optional `options` argument can be a string specifying an encoding, or an
2011
- * object with an `encoding` property specifying the character encoding to use for
2012
- * the filenames returned. If the `encoding` is set to `'buffer'`,
2013
- * the filenames returned will be passed as `Buffer` objects.
2014
- *
2015
- * If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects.
2016
- * @since v0.1.21
2017
- */
2018
- export function readdirSync(
2019
- path: PathLike,
2020
- options?:
2021
- | {
2022
- encoding: BufferEncoding | null;
2023
- withFileTypes?: false | undefined;
2024
- recursive?: boolean | undefined;
2025
- }
2026
- | BufferEncoding
2027
- | null
2028
- ): string[];
2029
- /**
2030
- * Synchronous readdir(3) - read a directory.
2031
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2032
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2033
- */
2034
- export function readdirSync(
2035
- path: PathLike,
2036
- options:
2037
- | {
2038
- encoding: 'buffer';
2039
- withFileTypes?: false | undefined;
2040
- recursive?: boolean | undefined;
2041
- }
2042
- | 'buffer'
2043
- ): Buffer[];
2044
- /**
2045
- * Synchronous readdir(3) - read a directory.
2046
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2047
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2048
- */
2049
- export function readdirSync(
2050
- path: PathLike,
2051
- options?:
2052
- | (ObjectEncodingOptions & {
2053
- withFileTypes?: false | undefined;
2054
- recursive?: boolean | undefined;
2055
- })
2056
- | BufferEncoding
2057
- | null
2058
- ): string[] | Buffer[];
2059
- /**
2060
- * Synchronous readdir(3) - read a directory.
2061
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2062
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
2063
- */
2064
- export function readdirSync(
2065
- path: PathLike,
2066
- options: ObjectEncodingOptions & {
2067
- withFileTypes: true;
2068
- recursive?: boolean | undefined;
2069
- }
2070
- ): Dirent[];
2071
- /**
2072
- * Closes the file descriptor. No arguments other than a possible exception are
2073
- * given to the completion callback.
2074
- *
2075
- * Calling `fs.close()` on any file descriptor (`fd`) that is currently in use
2076
- * through any other `fs` operation may lead to undefined behavior.
2077
- *
2078
- * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
2079
- * @since v0.0.2
2080
- */
2081
- export function close(fd: number, callback?: NoParamCallback): void;
2082
- export namespace close {
2083
- /**
2084
- * Asynchronous close(2) - close a file descriptor.
2085
- * @param fd A file descriptor.
2086
- */
2087
- function __promisify__(fd: number): Promise<void>;
2088
- }
2089
- /**
2090
- * Closes the file descriptor. Returns `undefined`.
2091
- *
2092
- * Calling `fs.closeSync()` on any file descriptor (`fd`) that is currently in use
2093
- * through any other `fs` operation may lead to undefined behavior.
2094
- *
2095
- * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
2096
- * @since v0.1.21
2097
- */
2098
- export function closeSync(fd: number): void;
2099
- /**
2100
- * Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details.
2101
- *
2102
- * `mode` sets the file mode (permission and sticky bits), but only if the file was
2103
- * created. On Windows, only the write permission can be manipulated; see {@link chmod}.
2104
- *
2105
- * The callback gets two arguments `(err, fd)`.
2106
- *
2107
- * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
2108
- * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
2109
- * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
2110
- *
2111
- * Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc.
2112
- * @since v0.0.2
2113
- * @param [flags='r'] See `support of file system `flags``.
2114
- * @param [mode=0o666]
2115
- */
2116
- export function open(path: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
2117
- /**
2118
- * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
2119
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2120
- * @param [flags='r'] See `support of file system `flags``.
2121
- */
2122
- export function open(path: PathLike, flags: OpenMode | undefined, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
2123
- /**
2124
- * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
2125
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2126
- */
2127
- export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
2128
- export namespace open {
2129
- /**
2130
- * Asynchronous open(2) - open and possibly create a file.
2131
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2132
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
2133
- */
2134
- function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise<number>;
2135
- }
2136
- /**
2137
- * Returns an integer representing the file descriptor.
2138
- *
2139
- * For detailed information, see the documentation of the asynchronous version of
2140
- * this API: {@link open}.
2141
- * @since v0.1.21
2142
- * @param [flags='r']
2143
- * @param [mode=0o666]
2144
- */
2145
- export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
2146
- /**
2147
- * Change the file system timestamps of the object referenced by `path`.
2148
- *
2149
- * The `atime` and `mtime` arguments follow these rules:
2150
- *
2151
- * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`.
2152
- * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown.
2153
- * @since v0.4.2
2154
- */
2155
- export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
2156
- export namespace utimes {
2157
- /**
2158
- * Asynchronously change file timestamps of the file referenced by the supplied path.
2159
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2160
- * @param atime The last access time. If a string is provided, it will be coerced to number.
2161
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2162
- */
2163
- function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
2164
- }
2165
- /**
2166
- * Returns `undefined`.
2167
- *
2168
- * For detailed information, see the documentation of the asynchronous version of
2169
- * this API: {@link utimes}.
2170
- * @since v0.4.2
2171
- */
2172
- export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
2173
- /**
2174
- * Change the file system timestamps of the object referenced by the supplied file
2175
- * descriptor. See {@link utimes}.
2176
- * @since v0.4.2
2177
- */
2178
- export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
2179
- export namespace futimes {
2180
- /**
2181
- * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
2182
- * @param fd A file descriptor.
2183
- * @param atime The last access time. If a string is provided, it will be coerced to number.
2184
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2185
- */
2186
- function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
2187
- }
2188
- /**
2189
- * Synchronous version of {@link futimes}. Returns `undefined`.
2190
- * @since v0.4.2
2191
- */
2192
- export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
2193
- /**
2194
- * Request that all data for the open file descriptor is flushed to the storage
2195
- * device. The specific implementation is operating system and device specific.
2196
- * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. No arguments other
2197
- * than a possible exception are given to the completion callback.
2198
- * @since v0.1.96
2199
- */
2200
- export function fsync(fd: number, callback: NoParamCallback): void;
2201
- export namespace fsync {
2202
- /**
2203
- * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
2204
- * @param fd A file descriptor.
2205
- */
2206
- function __promisify__(fd: number): Promise<void>;
2207
- }
2208
- /**
2209
- * Request that all data for the open file descriptor is flushed to the storage
2210
- * device. The specific implementation is operating system and device specific.
2211
- * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail. Returns `undefined`.
2212
- * @since v0.1.96
2213
- */
2214
- export function fsyncSync(fd: number): void;
2215
- /**
2216
- * Write `buffer` to the file specified by `fd`.
2217
- *
2218
- * `offset` determines the part of the buffer to be written, and `length` is
2219
- * an integer specifying the number of bytes to write.
2220
- *
2221
- * `position` refers to the offset from the beginning of the file where this data
2222
- * should be written. If `typeof position !== 'number'`, the data will be written
2223
- * at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).
2224
- *
2225
- * The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`.
2226
- *
2227
- * If this method is invoked as its `util.promisify()` ed version, it returns
2228
- * a promise for an `Object` with `bytesWritten` and `buffer` properties.
2229
- *
2230
- * It is unsafe to use `fs.write()` multiple times on the same file without waiting
2231
- * for the callback. For this scenario, {@link createWriteStream} is
2232
- * recommended.
2233
- *
2234
- * On Linux, positional writes don't work when the file is opened in append mode.
2235
- * The kernel ignores the position argument and always appends the data to
2236
- * the end of the file.
2237
- * @since v0.0.2
2238
- * @param [offset=0]
2239
- * @param [length=buffer.byteLength - offset]
2240
- * @param [position='null']
2241
- */
2242
- export function write<TBuffer extends NodeJS.ArrayBufferView>(
2243
- fd: number,
2244
- buffer: TBuffer,
2245
- offset: number | undefined | null,
2246
- length: number | undefined | null,
2247
- position: number | undefined | null,
2248
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
2249
- ): void;
2250
- /**
2251
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2252
- * @param fd A file descriptor.
2253
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2254
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2255
- */
2256
- export function write<TBuffer extends NodeJS.ArrayBufferView>(
2257
- fd: number,
2258
- buffer: TBuffer,
2259
- offset: number | undefined | null,
2260
- length: number | undefined | null,
2261
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
2262
- ): void;
2263
- /**
2264
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2265
- * @param fd A file descriptor.
2266
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2267
- */
2268
- export function write<TBuffer extends NodeJS.ArrayBufferView>(
2269
- fd: number,
2270
- buffer: TBuffer,
2271
- offset: number | undefined | null,
2272
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
2273
- ): void;
2274
- /**
2275
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2276
- * @param fd A file descriptor.
2277
- */
2278
- export function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
2279
- /**
2280
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2281
- * @param fd A file descriptor.
2282
- * @param string A string to write.
2283
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2284
- * @param encoding The expected string encoding.
2285
- */
2286
- export function write(
2287
- fd: number,
2288
- string: string,
2289
- position: number | undefined | null,
2290
- encoding: BufferEncoding | undefined | null,
2291
- callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void
2292
- ): void;
2293
- /**
2294
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2295
- * @param fd A file descriptor.
2296
- * @param string A string to write.
2297
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2298
- */
2299
- export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
2300
- /**
2301
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2302
- * @param fd A file descriptor.
2303
- * @param string A string to write.
2304
- */
2305
- export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
2306
- export namespace write {
2307
- /**
2308
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
2309
- * @param fd A file descriptor.
2310
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2311
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2312
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2313
- */
2314
- function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2315
- fd: number,
2316
- buffer?: TBuffer,
2317
- offset?: number,
2318
- length?: number,
2319
- position?: number | null
2320
- ): Promise<{
2321
- bytesWritten: number;
2322
- buffer: TBuffer;
2323
- }>;
2324
- /**
2325
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
2326
- * @param fd A file descriptor.
2327
- * @param string A string to write.
2328
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2329
- * @param encoding The expected string encoding.
2330
- */
2331
- function __promisify__(
2332
- fd: number,
2333
- string: string,
2334
- position?: number | null,
2335
- encoding?: BufferEncoding | null
2336
- ): Promise<{
2337
- bytesWritten: number;
2338
- buffer: string;
2339
- }>;
2340
- }
2341
- /**
2342
- * For detailed information, see the documentation of the asynchronous version of
2343
- * this API: {@link write}.
2344
- * @since v0.1.21
2345
- * @param [offset=0]
2346
- * @param [length=buffer.byteLength - offset]
2347
- * @param [position='null']
2348
- * @return The number of bytes written.
2349
- */
2350
- export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
2351
- /**
2352
- * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
2353
- * @param fd A file descriptor.
2354
- * @param string A string to write.
2355
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2356
- * @param encoding The expected string encoding.
2357
- */
2358
- export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
2359
- export type ReadPosition = number | bigint;
2360
- export interface ReadSyncOptions {
2361
- /**
2362
- * @default 0
2363
- */
2364
- offset?: number | undefined;
2365
- /**
2366
- * @default `length of buffer`
2367
- */
2368
- length?: number | undefined;
2369
- /**
2370
- * @default null
2371
- */
2372
- position?: ReadPosition | null | undefined;
2373
- }
2374
- export interface ReadAsyncOptions<TBuffer extends NodeJS.ArrayBufferView> extends ReadSyncOptions {
2375
- buffer?: TBuffer;
2376
- }
2377
- /**
2378
- * Read data from the file specified by `fd`.
2379
- *
2380
- * The callback is given the three arguments, `(err, bytesRead, buffer)`.
2381
- *
2382
- * If the file is not modified concurrently, the end-of-file is reached when the
2383
- * number of bytes read is zero.
2384
- *
2385
- * If this method is invoked as its `util.promisify()` ed version, it returns
2386
- * a promise for an `Object` with `bytesRead` and `buffer` properties.
2387
- * @since v0.0.2
2388
- * @param buffer The buffer that the data will be written to.
2389
- * @param offset The position in `buffer` to write the data to.
2390
- * @param length The number of bytes to read.
2391
- * @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If
2392
- * `position` is an integer, the file position will be unchanged.
2393
- */
2394
- export function read<TBuffer extends NodeJS.ArrayBufferView>(
2395
- fd: number,
2396
- buffer: TBuffer,
2397
- offset: number,
2398
- length: number,
2399
- position: ReadPosition | null,
2400
- callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
2401
- ): void;
2402
- /**
2403
- * Similar to the above `fs.read` function, this version takes an optional `options` object.
2404
- * If not otherwise specified in an `options` object,
2405
- * `buffer` defaults to `Buffer.alloc(16384)`,
2406
- * `offset` defaults to `0`,
2407
- * `length` defaults to `buffer.byteLength`, `- offset` as of Node 17.6.0
2408
- * `position` defaults to `null`
2409
- * @since v12.17.0, 13.11.0
2410
- */
2411
- export function read<TBuffer extends NodeJS.ArrayBufferView>(
2412
- fd: number,
2413
- options: ReadAsyncOptions<TBuffer>,
2414
- callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
2415
- ): void;
2416
- export function read(fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
2417
- export namespace read {
2418
- /**
2419
- * @param fd A file descriptor.
2420
- * @param buffer The buffer that the data will be written to.
2421
- * @param offset The offset in the buffer at which to start writing.
2422
- * @param length The number of bytes to read.
2423
- * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
2424
- */
2425
- function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2426
- fd: number,
2427
- buffer: TBuffer,
2428
- offset: number,
2429
- length: number,
2430
- position: number | null
2431
- ): Promise<{
2432
- bytesRead: number;
2433
- buffer: TBuffer;
2434
- }>;
2435
- function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2436
- fd: number,
2437
- options: ReadAsyncOptions<TBuffer>
2438
- ): Promise<{
2439
- bytesRead: number;
2440
- buffer: TBuffer;
2441
- }>;
2442
- function __promisify__(fd: number): Promise<{
2443
- bytesRead: number;
2444
- buffer: NodeJS.ArrayBufferView;
2445
- }>;
2446
- }
2447
- /**
2448
- * Returns the number of `bytesRead`.
2449
- *
2450
- * For detailed information, see the documentation of the asynchronous version of
2451
- * this API: {@link read}.
2452
- * @since v0.1.21
2453
- * @param [position='null']
2454
- */
2455
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number;
2456
- /**
2457
- * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
2458
- * If no `options` object is specified, it will default with the above values.
2459
- */
2460
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
2461
- /**
2462
- * Asynchronously reads the entire contents of a file.
2463
- *
2464
- * ```js
2465
- * import { readFile } from 'node:fs';
2466
- *
2467
- * readFile('/etc/passwd', (err, data) => {
2468
- * if (err) throw err;
2469
- * console.log(data);
2470
- * });
2471
- * ```
2472
- *
2473
- * The callback is passed two arguments `(err, data)`, where `data` is the
2474
- * contents of the file.
2475
- *
2476
- * If no encoding is specified, then the raw buffer is returned.
2477
- *
2478
- * If `options` is a string, then it specifies the encoding:
2479
- *
2480
- * ```js
2481
- * import { readFile } from 'node:fs';
2482
- *
2483
- * readFile('/etc/passwd', 'utf8', callback);
2484
- * ```
2485
- *
2486
- * When the path is a directory, the behavior of `fs.readFile()` and {@link readFileSync} is platform-specific. On macOS, Linux, and Windows, an
2487
- * error will be returned. On FreeBSD, a representation of the directory's contents
2488
- * will be returned.
2489
- *
2490
- * ```js
2491
- * import { readFile } from 'node:fs';
2492
- *
2493
- * // macOS, Linux, and Windows
2494
- * readFile('<directory>', (err, data) => {
2495
- * // => [Error: EISDIR: illegal operation on a directory, read <directory>]
2496
- * });
2497
- *
2498
- * // FreeBSD
2499
- * readFile('<directory>', (err, data) => {
2500
- * // => null, <data>
2501
- * });
2502
- * ```
2503
- *
2504
- * It is possible to abort an ongoing request using an `AbortSignal`. If a
2505
- * request is aborted the callback is called with an `AbortError`:
2506
- *
2507
- * ```js
2508
- * import { readFile } from 'node:fs';
2509
- *
2510
- * const controller = new AbortController();
2511
- * const signal = controller.signal;
2512
- * readFile(fileInfo[0].name, { signal }, (err, buf) => {
2513
- * // ...
2514
- * });
2515
- * // When you want to abort the request
2516
- * controller.abort();
2517
- * ```
2518
- *
2519
- * The `fs.readFile()` function buffers the entire file. To minimize memory costs,
2520
- * when possible prefer streaming via `fs.createReadStream()`.
2521
- *
2522
- * Aborting an ongoing request does not abort individual operating
2523
- * system requests but rather the internal buffering `fs.readFile` performs.
2524
- * @since v0.1.29
2525
- * @param path filename or file descriptor
2526
- */
2527
- export function readFile(
2528
- path: PathOrFileDescriptor,
2529
- options:
2530
- | ({
2531
- encoding?: null | undefined;
2532
- flag?: string | undefined;
2533
- } & Abortable)
2534
- | undefined
2535
- | null,
2536
- callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void
2537
- ): void;
2538
- /**
2539
- * Asynchronously reads the entire contents of a file.
2540
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2541
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2542
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2543
- * If a flag is not provided, it defaults to `'r'`.
2544
- */
2545
- export function readFile(
2546
- path: PathOrFileDescriptor,
2547
- options:
2548
- | ({
2549
- encoding: BufferEncoding;
2550
- flag?: string | undefined;
2551
- } & Abortable)
2552
- | BufferEncoding,
2553
- callback: (err: NodeJS.ErrnoException | null, data: string) => void
2554
- ): void;
2555
- /**
2556
- * Asynchronously reads the entire contents of a file.
2557
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2558
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2559
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2560
- * If a flag is not provided, it defaults to `'r'`.
2561
- */
2562
- export function readFile(
2563
- path: PathOrFileDescriptor,
2564
- options:
2565
- | (ObjectEncodingOptions & {
2566
- flag?: string | undefined;
2567
- } & Abortable)
2568
- | BufferEncoding
2569
- | undefined
2570
- | null,
2571
- callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void
2572
- ): void;
2573
- /**
2574
- * Asynchronously reads the entire contents of a file.
2575
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2576
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2577
- */
2578
- export function readFile(path: PathOrFileDescriptor, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
2579
- export namespace readFile {
2580
- /**
2581
- * Asynchronously reads the entire contents of a file.
2582
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2583
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2584
- * @param options An object that may contain an optional flag.
2585
- * If a flag is not provided, it defaults to `'r'`.
2586
- */
2587
- function __promisify__(
2588
- path: PathOrFileDescriptor,
2589
- options?: {
2590
- encoding?: null | undefined;
2591
- flag?: string | undefined;
2592
- } | null
2593
- ): Promise<Buffer>;
2594
- /**
2595
- * Asynchronously reads the entire contents of a file.
2596
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2597
- * URL support is _experimental_.
2598
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2599
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2600
- * If a flag is not provided, it defaults to `'r'`.
2601
- */
2602
- function __promisify__(
2603
- path: PathOrFileDescriptor,
2604
- options:
2605
- | {
2606
- encoding: BufferEncoding;
2607
- flag?: string | undefined;
2608
- }
2609
- | BufferEncoding
2610
- ): Promise<string>;
2611
- /**
2612
- * Asynchronously reads the entire contents of a file.
2613
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2614
- * URL support is _experimental_.
2615
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2616
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2617
- * If a flag is not provided, it defaults to `'r'`.
2618
- */
2619
- function __promisify__(
2620
- path: PathOrFileDescriptor,
2621
- options?:
2622
- | (ObjectEncodingOptions & {
2623
- flag?: string | undefined;
2624
- })
2625
- | BufferEncoding
2626
- | null
2627
- ): Promise<string | Buffer>;
2628
- }
2629
- /**
2630
- * Returns the contents of the `path`.
2631
- *
2632
- * For detailed information, see the documentation of the asynchronous version of
2633
- * this API: {@link readFile}.
2634
- *
2635
- * If the `encoding` option is specified then this function returns a
2636
- * string. Otherwise it returns a buffer.
2637
- *
2638
- * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific.
2639
- *
2640
- * ```js
2641
- * import { readFileSync } from 'node:fs';
2642
- *
2643
- * // macOS, Linux, and Windows
2644
- * readFileSync('<directory>');
2645
- * // => [Error: EISDIR: illegal operation on a directory, read <directory>]
2646
- *
2647
- * // FreeBSD
2648
- * readFileSync('<directory>'); // => <data>
2649
- * ```
2650
- * @since v0.1.8
2651
- * @param path filename or file descriptor
2652
- */
2653
- export function readFileSync(
2654
- path: PathOrFileDescriptor,
2655
- options?: {
2656
- encoding?: null | undefined;
2657
- flag?: string | undefined;
2658
- } | null
2659
- ): Buffer;
2660
- /**
2661
- * Synchronously reads the entire contents of a file.
2662
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2663
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2664
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2665
- * If a flag is not provided, it defaults to `'r'`.
2666
- */
2667
- export function readFileSync(
2668
- path: PathOrFileDescriptor,
2669
- options:
2670
- | {
2671
- encoding: BufferEncoding;
2672
- flag?: string | undefined;
2673
- }
2674
- | BufferEncoding
2675
- ): string;
2676
- /**
2677
- * Synchronously reads the entire contents of a file.
2678
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2679
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2680
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
2681
- * If a flag is not provided, it defaults to `'r'`.
2682
- */
2683
- export function readFileSync(
2684
- path: PathOrFileDescriptor,
2685
- options?:
2686
- | (ObjectEncodingOptions & {
2687
- flag?: string | undefined;
2688
- })
2689
- | BufferEncoding
2690
- | null
2691
- ): string | Buffer;
2692
- export type WriteFileOptions =
2693
- | (ObjectEncodingOptions &
2694
- Abortable & {
2695
- mode?: Mode | undefined;
2696
- flag?: string | undefined;
2697
- })
2698
- | BufferEncoding
2699
- | null;
2700
- /**
2701
- * When `file` is a filename, asynchronously writes data to the file, replacing the
2702
- * file if it already exists. `data` can be a string or a buffer.
2703
- *
2704
- * When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using
2705
- * a file descriptor.
2706
- *
2707
- * The `encoding` option is ignored if `data` is a buffer.
2708
- *
2709
- * The `mode` option only affects the newly created file. See {@link open} for more details.
2710
- *
2711
- * ```js
2712
- * import { writeFile } from 'node:fs';
2713
- * import { Buffer } from 'node:buffer';
2714
- *
2715
- * const data = new Uint8Array(Buffer.from('Hello Node.js'));
2716
- * writeFile('message.txt', data, (err) => {
2717
- * if (err) throw err;
2718
- * console.log('The file has been saved!');
2719
- * });
2720
- * ```
2721
- *
2722
- * If `options` is a string, then it specifies the encoding:
2723
- *
2724
- * ```js
2725
- * import { writeFile } from 'node:fs';
2726
- *
2727
- * writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
2728
- * ```
2729
- *
2730
- * It is unsafe to use `fs.writeFile()` multiple times on the same file without
2731
- * waiting for the callback. For this scenario, {@link createWriteStream} is
2732
- * recommended.
2733
- *
2734
- * Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that
2735
- * performs multiple `write` calls internally to write the buffer passed to it.
2736
- * For performance sensitive code consider using {@link createWriteStream}.
2737
- *
2738
- * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`.
2739
- * Cancelation is "best effort", and some amount of data is likely still
2740
- * to be written.
2741
- *
2742
- * ```js
2743
- * import { writeFile } from 'node:fs';
2744
- * import { Buffer } from 'node:buffer';
2745
- *
2746
- * const controller = new AbortController();
2747
- * const { signal } = controller;
2748
- * const data = new Uint8Array(Buffer.from('Hello Node.js'));
2749
- * writeFile('message.txt', data, { signal }, (err) => {
2750
- * // When a request is aborted - the callback is called with an AbortError
2751
- * });
2752
- * // When the request should be aborted
2753
- * controller.abort();
2754
- * ```
2755
- *
2756
- * Aborting an ongoing request does not abort individual operating
2757
- * system requests but rather the internal buffering `fs.writeFile` performs.
2758
- * @since v0.1.29
2759
- * @param file filename or file descriptor
2760
- */
2761
- export function writeFile(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
2762
- /**
2763
- * Asynchronously writes data to a file, replacing the file if it already exists.
2764
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2765
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2766
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
2767
- */
2768
- export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
2769
- export namespace writeFile {
2770
- /**
2771
- * Asynchronously writes data to a file, replacing the file if it already exists.
2772
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2773
- * URL support is _experimental_.
2774
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2775
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
2776
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2777
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2778
- * If `mode` is not supplied, the default of `0o666` is used.
2779
- * If `mode` is a string, it is parsed as an octal integer.
2780
- * If `flag` is not supplied, the default of `'w'` is used.
2781
- */
2782
- function __promisify__(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
2783
- }
2784
- /**
2785
- * Returns `undefined`.
2786
- *
2787
- * The `mode` option only affects the newly created file. See {@link open} for more details.
2788
- *
2789
- * For detailed information, see the documentation of the asynchronous version of
2790
- * this API: {@link writeFile}.
2791
- * @since v0.1.29
2792
- * @param file filename or file descriptor
2793
- */
2794
- export function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
2795
- /**
2796
- * Asynchronously append data to a file, creating the file if it does not yet
2797
- * exist. `data` can be a string or a `Buffer`.
2798
- *
2799
- * The `mode` option only affects the newly created file. See {@link open} for more details.
2800
- *
2801
- * ```js
2802
- * import { appendFile } from 'node:fs';
2803
- *
2804
- * appendFile('message.txt', 'data to append', (err) => {
2805
- * if (err) throw err;
2806
- * console.log('The "data to append" was appended to file!');
2807
- * });
2808
- * ```
2809
- *
2810
- * If `options` is a string, then it specifies the encoding:
2811
- *
2812
- * ```js
2813
- * import { appendFile } from 'node:fs';
2814
- *
2815
- * appendFile('message.txt', 'data to append', 'utf8', callback);
2816
- * ```
2817
- *
2818
- * The `path` may be specified as a numeric file descriptor that has been opened
2819
- * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
2820
- * not be closed automatically.
2821
- *
2822
- * ```js
2823
- * import { open, close, appendFile } from 'node:fs';
2824
- *
2825
- * function closeFd(fd) {
2826
- * close(fd, (err) => {
2827
- * if (err) throw err;
2828
- * });
2829
- * }
2830
- *
2831
- * open('message.txt', 'a', (err, fd) => {
2832
- * if (err) throw err;
2833
- *
2834
- * try {
2835
- * appendFile(fd, 'data to append', 'utf8', (err) => {
2836
- * closeFd(fd);
2837
- * if (err) throw err;
2838
- * });
2839
- * } catch (err) {
2840
- * closeFd(fd);
2841
- * throw err;
2842
- * }
2843
- * });
2844
- * ```
2845
- * @since v0.6.7
2846
- * @param path filename or file descriptor
2847
- */
2848
- export function appendFile(path: PathOrFileDescriptor, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
2849
- /**
2850
- * Asynchronously append data to a file, creating the file if it does not exist.
2851
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
2852
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2853
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
2854
- */
2855
- export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
2856
- export namespace appendFile {
2857
- /**
2858
- * Asynchronously append data to a file, creating the file if it does not exist.
2859
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
2860
- * URL support is _experimental_.
2861
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
2862
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
2863
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2864
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2865
- * If `mode` is not supplied, the default of `0o666` is used.
2866
- * If `mode` is a string, it is parsed as an octal integer.
2867
- * If `flag` is not supplied, the default of `'a'` is used.
2868
- */
2869
- function __promisify__(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
2870
- }
2871
- /**
2872
- * Synchronously append data to a file, creating the file if it does not yet
2873
- * exist. `data` can be a string or a `Buffer`.
2874
- *
2875
- * The `mode` option only affects the newly created file. See {@link open} for more details.
2876
- *
2877
- * ```js
2878
- * import { appendFileSync } from 'node:fs';
2879
- *
2880
- * try {
2881
- * appendFileSync('message.txt', 'data to append');
2882
- * console.log('The "data to append" was appended to file!');
2883
- * } catch (err) {
2884
- * // Handle the error
2885
- * }
2886
- * ```
2887
- *
2888
- * If `options` is a string, then it specifies the encoding:
2889
- *
2890
- * ```js
2891
- * import { appendFileSync } from 'node:fs';
2892
- *
2893
- * appendFileSync('message.txt', 'data to append', 'utf8');
2894
- * ```
2895
- *
2896
- * The `path` may be specified as a numeric file descriptor that has been opened
2897
- * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
2898
- * not be closed automatically.
2899
- *
2900
- * ```js
2901
- * import { openSync, closeSync, appendFileSync } from 'node:fs';
2902
- *
2903
- * let fd;
2904
- *
2905
- * try {
2906
- * fd = openSync('message.txt', 'a');
2907
- * appendFileSync(fd, 'data to append', 'utf8');
2908
- * } catch (err) {
2909
- * // Handle the error
2910
- * } finally {
2911
- * if (fd !== undefined)
2912
- * closeSync(fd);
2913
- * }
2914
- * ```
2915
- * @since v0.6.7
2916
- * @param path filename or file descriptor
2917
- */
2918
- export function appendFileSync(path: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): void;
2919
- /**
2920
- * Watch for changes on `filename`. The callback `listener` will be called each
2921
- * time the file is accessed.
2922
- *
2923
- * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
2924
- * whether the process should continue to run as long as files are being watched.
2925
- * The `options` object may specify an `interval` property indicating how often the
2926
- * target should be polled in milliseconds.
2927
- *
2928
- * The `listener` gets two arguments the current stat object and the previous
2929
- * stat object:
2930
- *
2931
- * ```js
2932
- * import { watchFile } from 'fs';
2933
- *
2934
- * watchFile('message.text', (curr, prev) => {
2935
- * console.log(`the current mtime is: ${curr.mtime}`);
2936
- * console.log(`the previous mtime was: ${prev.mtime}`);
2937
- * });
2938
- * ```
2939
- *
2940
- * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
2941
- * the numeric values in these objects are specified as `BigInt`s.
2942
- *
2943
- * To be notified when the file was modified, not just accessed, it is necessary
2944
- * to compare `curr.mtimeMs` and `prev.mtimeMs`.
2945
- *
2946
- * When an `fs.watchFile` operation results in an `ENOENT` error, it
2947
- * will invoke the listener once, with all the fields zeroed (or, for dates, the
2948
- * Unix Epoch). If the file is created later on, the listener will be called
2949
- * again, with the latest stat objects. This is a change in functionality since
2950
- * v0.10.
2951
- *
2952
- * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
2953
- *
2954
- * When a file being watched by `fs.watchFile()` disappears and reappears,
2955
- * then the contents of `previous` in the second callback event (the file's
2956
- * reappearance) will be the same as the contents of `previous` in the first
2957
- * callback event (its disappearance).
2958
- *
2959
- * This happens when:
2960
- *
2961
- * * the file is deleted, followed by a restore
2962
- * * the file is renamed and then renamed a second time back to its original name
2963
- * @since v0.1.31
2964
- */
2965
- export interface WatchFileOptions {
2966
- bigint?: boolean | undefined;
2967
- persistent?: boolean | undefined;
2968
- interval?: number | undefined;
2969
- }
2970
- /**
2971
- * Watch for changes on `filename`. The callback `listener` will be called each
2972
- * time the file is accessed.
2973
- *
2974
- * The `options` argument may be omitted. If provided, it should be an object. The`options` object may contain a boolean named `persistent` that indicates
2975
- * whether the process should continue to run as long as files are being watched.
2976
- * The `options` object may specify an `interval` property indicating how often the
2977
- * target should be polled in milliseconds.
2978
- *
2979
- * The `listener` gets two arguments the current stat object and the previous
2980
- * stat object:
2981
- *
2982
- * ```js
2983
- * import { watchFile } from 'node:fs';
2984
- *
2985
- * watchFile('message.text', (curr, prev) => {
2986
- * console.log(`the current mtime is: ${curr.mtime}`);
2987
- * console.log(`the previous mtime was: ${prev.mtime}`);
2988
- * });
2989
- * ```
2990
- *
2991
- * These stat objects are instances of `fs.Stat`. If the `bigint` option is `true`,
2992
- * the numeric values in these objects are specified as `BigInt`s.
2993
- *
2994
- * To be notified when the file was modified, not just accessed, it is necessary
2995
- * to compare `curr.mtimeMs` and `prev.mtimeMs`.
2996
- *
2997
- * When an `fs.watchFile` operation results in an `ENOENT` error, it
2998
- * will invoke the listener once, with all the fields zeroed (or, for dates, the
2999
- * Unix Epoch). If the file is created later on, the listener will be called
3000
- * again, with the latest stat objects. This is a change in functionality since
3001
- * v0.10.
3002
- *
3003
- * Using {@link watch} is more efficient than `fs.watchFile` and`fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and`fs.unwatchFile` when possible.
3004
- *
3005
- * When a file being watched by `fs.watchFile()` disappears and reappears,
3006
- * then the contents of `previous` in the second callback event (the file's
3007
- * reappearance) will be the same as the contents of `previous` in the first
3008
- * callback event (its disappearance).
3009
- *
3010
- * This happens when:
3011
- *
3012
- * * the file is deleted, followed by a restore
3013
- * * the file is renamed and then renamed a second time back to its original name
3014
- * @since v0.1.31
3015
- */
3016
- export function watchFile(
3017
- filename: PathLike,
3018
- options:
3019
- | (WatchFileOptions & {
3020
- bigint?: false | undefined;
3021
- })
3022
- | undefined,
3023
- listener: StatsListener
3024
- ): StatWatcher;
3025
- export function watchFile(
3026
- filename: PathLike,
3027
- options:
3028
- | (WatchFileOptions & {
3029
- bigint: true;
3030
- })
3031
- | undefined,
3032
- listener: BigIntStatsListener
3033
- ): StatWatcher;
3034
- /**
3035
- * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
3036
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3037
- */
3038
- export function watchFile(filename: PathLike, listener: StatsListener): StatWatcher;
3039
- /**
3040
- * Stop watching for changes on `filename`. If `listener` is specified, only that
3041
- * particular listener is removed. Otherwise, _all_ listeners are removed,
3042
- * effectively stopping watching of `filename`.
3043
- *
3044
- * Calling `fs.unwatchFile()` with a filename that is not being watched is a
3045
- * no-op, not an error.
3046
- *
3047
- * Using {@link watch} is more efficient than `fs.watchFile()` and`fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()`and `fs.unwatchFile()` when possible.
3048
- * @since v0.1.31
3049
- * @param listener Optional, a listener previously attached using `fs.watchFile()`
3050
- */
3051
- export function unwatchFile(filename: PathLike, listener?: StatsListener): void;
3052
- export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void;
3053
- export interface WatchOptions extends Abortable {
3054
- encoding?: BufferEncoding | 'buffer' | undefined;
3055
- persistent?: boolean | undefined;
3056
- recursive?: boolean | undefined;
3057
- }
3058
- export type WatchEventType = 'rename' | 'change';
3059
- export type WatchListener<T> = (event: WatchEventType, filename: T) => void;
3060
- export type StatsListener = (curr: Stats, prev: Stats) => void;
3061
- export type BigIntStatsListener = (curr: BigIntStats, prev: BigIntStats) => void;
3062
- /**
3063
- * Watch for changes on `filename`, where `filename` is either a file or a
3064
- * directory.
3065
- *
3066
- * The second argument is optional. If `options` is provided as a string, it
3067
- * specifies the `encoding`. Otherwise `options` should be passed as an object.
3068
- *
3069
- * The listener callback gets two arguments `(eventType, filename)`. `eventType`is either `'rename'` or `'change'`, and `filename` is the name of the file
3070
- * which triggered the event.
3071
- *
3072
- * On most platforms, `'rename'` is emitted whenever a filename appears or
3073
- * disappears in the directory.
3074
- *
3075
- * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`.
3076
- *
3077
- * If a `signal` is passed, aborting the corresponding AbortController will close
3078
- * the returned `fs.FSWatcher`.
3079
- * @since v0.5.10
3080
- * @param listener
3081
- */
3082
- export function watch(
3083
- filename: PathLike,
3084
- options:
3085
- | (WatchOptions & {
3086
- encoding: 'buffer';
3087
- })
3088
- | 'buffer',
3089
- listener?: WatchListener<Buffer>
3090
- ): FSWatcher;
3091
- /**
3092
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3093
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3094
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3095
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3096
- * If `persistent` is not supplied, the default of `true` is used.
3097
- * If `recursive` is not supplied, the default of `false` is used.
3098
- */
3099
- export function watch(filename: PathLike, options?: WatchOptions | BufferEncoding | null, listener?: WatchListener<string>): FSWatcher;
3100
- /**
3101
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3102
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3103
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3104
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3105
- * If `persistent` is not supplied, the default of `true` is used.
3106
- * If `recursive` is not supplied, the default of `false` is used.
3107
- */
3108
- export function watch(filename: PathLike, options: WatchOptions | string, listener?: WatchListener<string | Buffer>): FSWatcher;
3109
- /**
3110
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3111
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3112
- */
3113
- export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
3114
- /**
3115
- * Test whether or not the given path exists by checking with the file system.
3116
- * Then call the `callback` argument with either true or false:
3117
- *
3118
- * ```js
3119
- * import { exists } from 'node:fs';
3120
- *
3121
- * exists('/etc/passwd', (e) => {
3122
- * console.log(e ? 'it exists' : 'no passwd!');
3123
- * });
3124
- * ```
3125
- *
3126
- * **The parameters for this callback are not consistent with other Node.js**
3127
- * **callbacks.** Normally, the first parameter to a Node.js callback is an `err`parameter, optionally followed by other parameters. The `fs.exists()` callback
3128
- * has only one boolean parameter. This is one reason `fs.access()` is recommended
3129
- * instead of `fs.exists()`.
3130
- *
3131
- * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing
3132
- * so introduces a race condition, since other processes may change the file's
3133
- * state between the two calls. Instead, user code should open/read/write the
3134
- * file directly and handle the error raised if the file does not exist.
3135
- *
3136
- * **write (NOT RECOMMENDED)**
3137
- *
3138
- * ```js
3139
- * import { exists, open, close } from 'node:fs';
3140
- *
3141
- * exists('myfile', (e) => {
3142
- * if (e) {
3143
- * console.error('myfile already exists');
3144
- * } else {
3145
- * open('myfile', 'wx', (err, fd) => {
3146
- * if (err) throw err;
3147
- *
3148
- * try {
3149
- * writeMyData(fd);
3150
- * } finally {
3151
- * close(fd, (err) => {
3152
- * if (err) throw err;
3153
- * });
3154
- * }
3155
- * });
3156
- * }
3157
- * });
3158
- * ```
3159
- *
3160
- * **write (RECOMMENDED)**
3161
- *
3162
- * ```js
3163
- * import { open, close } from 'node:fs';
3164
- * open('myfile', 'wx', (err, fd) => {
3165
- * if (err) {
3166
- * if (err.code === 'EEXIST') {
3167
- * console.error('myfile already exists');
3168
- * return;
3169
- * }
3170
- *
3171
- * throw err;
3172
- * }
3173
- *
3174
- * try {
3175
- * writeMyData(fd);
3176
- * } finally {
3177
- * close(fd, (err) => {
3178
- * if (err) throw err;
3179
- * });
3180
- * }
3181
- * });
3182
- * ```
3183
- *
3184
- * **read (NOT RECOMMENDED)**
3185
- *
3186
- * ```js
3187
- * import { open, close, exists } from 'node:fs';
3188
- *
3189
- * exists('myfile', (e) => {
3190
- * if (e) {
3191
- * open('myfile', 'r', (err, fd) => {
3192
- * if (err) throw err;
3193
- *
3194
- * try {
3195
- * readMyData(fd);
3196
- * } finally {
3197
- * close(fd, (err) => {
3198
- * if (err) throw err;
3199
- * });
3200
- * }
3201
- * });
3202
- * } else {
3203
- * console.error('myfile does not exist');
3204
- * }
3205
- * });
3206
- * ```
3207
- *
3208
- * **read (RECOMMENDED)**
3209
- *
3210
- * ```js
3211
- * import { open, close } from 'node:fs';
3212
- *
3213
- * open('myfile', 'r', (err, fd) => {
3214
- * if (err) {
3215
- * if (err.code === 'ENOENT') {
3216
- * console.error('myfile does not exist');
3217
- * return;
3218
- * }
3219
- *
3220
- * throw err;
3221
- * }
3222
- *
3223
- * try {
3224
- * readMyData(fd);
3225
- * } finally {
3226
- * close(fd, (err) => {
3227
- * if (err) throw err;
3228
- * });
3229
- * }
3230
- * });
3231
- * ```
3232
- *
3233
- * The "not recommended" examples above check for existence and then use the
3234
- * file; the "recommended" examples are better because they use the file directly
3235
- * and handle the error, if any.
3236
- *
3237
- * In general, check for the existence of a file only if the file won't be
3238
- * used directly, for example when its existence is a signal from another
3239
- * process.
3240
- * @since v0.0.2
3241
- * @deprecated Since v1.0.0 - Use {@link stat} or {@link access} instead.
3242
- */
3243
- export function exists(path: PathLike, callback: (exists: boolean) => void): void;
3244
- /** @deprecated */
3245
- export namespace exists {
3246
- /**
3247
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3248
- * URL support is _experimental_.
3249
- */
3250
- function __promisify__(path: PathLike): Promise<boolean>;
3251
- }
3252
- /**
3253
- * Returns `true` if the path exists, `false` otherwise.
3254
- *
3255
- * For detailed information, see the documentation of the asynchronous version of
3256
- * this API: {@link exists}.
3257
- *
3258
- * `fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`parameter to `fs.exists()` accepts parameters that are inconsistent with other
3259
- * Node.js callbacks. `fs.existsSync()` does not use a callback.
3260
- *
3261
- * ```js
3262
- * import { existsSync } from 'node:fs';
3263
- *
3264
- * if (existsSync('/etc/passwd'))
3265
- * console.log('The path exists.');
3266
- * ```
3267
- * @since v0.1.21
3268
- */
3269
- export function existsSync(path: PathLike): boolean;
3270
- export namespace constants {
3271
- // File Access Constants
3272
- /** Constant for fs.access(). File is visible to the calling process. */
3273
- const F_OK: number;
3274
- /** Constant for fs.access(). File can be read by the calling process. */
3275
- const R_OK: number;
3276
- /** Constant for fs.access(). File can be written by the calling process. */
3277
- const W_OK: number;
3278
- /** Constant for fs.access(). File can be executed by the calling process. */
3279
- const X_OK: number;
3280
- // File Copy Constants
3281
- /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
3282
- const COPYFILE_EXCL: number;
3283
- /**
3284
- * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
3285
- * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
3286
- */
3287
- const COPYFILE_FICLONE: number;
3288
- /**
3289
- * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
3290
- * If the underlying platform does not support copy-on-write, then the operation will fail with an error.
3291
- */
3292
- const COPYFILE_FICLONE_FORCE: number;
3293
- // File Open Constants
3294
- /** Constant for fs.open(). Flag indicating to open a file for read-only access. */
3295
- const O_RDONLY: number;
3296
- /** Constant for fs.open(). Flag indicating to open a file for write-only access. */
3297
- const O_WRONLY: number;
3298
- /** Constant for fs.open(). Flag indicating to open a file for read-write access. */
3299
- const O_RDWR: number;
3300
- /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
3301
- const O_CREAT: number;
3302
- /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
3303
- const O_EXCL: number;
3304
- /**
3305
- * Constant for fs.open(). Flag indicating that if path identifies a terminal device,
3306
- * opening the path shall not cause that terminal to become the controlling terminal for the process
3307
- * (if the process does not already have one).
3308
- */
3309
- const O_NOCTTY: number;
3310
- /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
3311
- const O_TRUNC: number;
3312
- /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
3313
- const O_APPEND: number;
3314
- /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
3315
- const O_DIRECTORY: number;
3316
- /**
3317
- * constant for fs.open().
3318
- * Flag indicating reading accesses to the file system will no longer result in
3319
- * an update to the atime information associated with the file.
3320
- * This flag is available on Linux operating systems only.
3321
- */
3322
- const O_NOATIME: number;
3323
- /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
3324
- const O_NOFOLLOW: number;
3325
- /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
3326
- const O_SYNC: number;
3327
- /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
3328
- const O_DSYNC: number;
3329
- /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
3330
- const O_SYMLINK: number;
3331
- /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
3332
- const O_DIRECT: number;
3333
- /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
3334
- const O_NONBLOCK: number;
3335
- // File Type Constants
3336
- /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
3337
- const S_IFMT: number;
3338
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
3339
- const S_IFREG: number;
3340
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
3341
- const S_IFDIR: number;
3342
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
3343
- const S_IFCHR: number;
3344
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
3345
- const S_IFBLK: number;
3346
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
3347
- const S_IFIFO: number;
3348
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
3349
- const S_IFLNK: number;
3350
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
3351
- const S_IFSOCK: number;
3352
- // File Mode Constants
3353
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
3354
- const S_IRWXU: number;
3355
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
3356
- const S_IRUSR: number;
3357
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
3358
- const S_IWUSR: number;
3359
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
3360
- const S_IXUSR: number;
3361
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
3362
- const S_IRWXG: number;
3363
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
3364
- const S_IRGRP: number;
3365
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
3366
- const S_IWGRP: number;
3367
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
3368
- const S_IXGRP: number;
3369
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
3370
- const S_IRWXO: number;
3371
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
3372
- const S_IROTH: number;
3373
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
3374
- const S_IWOTH: number;
3375
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
3376
- const S_IXOTH: number;
3377
- /**
3378
- * When set, a memory file mapping is used to access the file. This flag
3379
- * is available on Windows operating systems only. On other operating systems,
3380
- * this flag is ignored.
3381
- */
3382
- const UV_FS_O_FILEMAP: number;
3383
- }
3384
- /**
3385
- * Tests a user's permissions for the file or directory specified by `path`.
3386
- * The `mode` argument is an optional integer that specifies the accessibility
3387
- * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
3388
- * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
3389
- * possible values of `mode`.
3390
- *
3391
- * The final argument, `callback`, is a callback function that is invoked with
3392
- * a possible error argument. If any of the accessibility checks fail, the error
3393
- * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable.
3394
- *
3395
- * ```js
3396
- * import { access, constants } from 'node:fs';
3397
- *
3398
- * const file = 'package.json';
3399
- *
3400
- * // Check if the file exists in the current directory.
3401
- * access(file, constants.F_OK, (err) => {
3402
- * console.log(`${file} ${err ? 'does not exist' : 'exists'}`);
3403
- * });
3404
- *
3405
- * // Check if the file is readable.
3406
- * access(file, constants.R_OK, (err) => {
3407
- * console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);
3408
- * });
3409
- *
3410
- * // Check if the file is writable.
3411
- * access(file, constants.W_OK, (err) => {
3412
- * console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
3413
- * });
3414
- *
3415
- * // Check if the file is readable and writable.
3416
- * access(file, constants.R_OK | constants.W_OK, (err) => {
3417
- * console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
3418
- * });
3419
- * ```
3420
- *
3421
- * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing
3422
- * so introduces a race condition, since other processes may change the file's
3423
- * state between the two calls. Instead, user code should open/read/write the
3424
- * file directly and handle the error raised if the file is not accessible.
3425
- *
3426
- * **write (NOT RECOMMENDED)**
3427
- *
3428
- * ```js
3429
- * import { access, open, close } from 'node:fs';
3430
- *
3431
- * access('myfile', (err) => {
3432
- * if (!err) {
3433
- * console.error('myfile already exists');
3434
- * return;
3435
- * }
3436
- *
3437
- * open('myfile', 'wx', (err, fd) => {
3438
- * if (err) throw err;
3439
- *
3440
- * try {
3441
- * writeMyData(fd);
3442
- * } finally {
3443
- * close(fd, (err) => {
3444
- * if (err) throw err;
3445
- * });
3446
- * }
3447
- * });
3448
- * });
3449
- * ```
3450
- *
3451
- * **write (RECOMMENDED)**
3452
- *
3453
- * ```js
3454
- * import { open, close } from 'node:fs';
3455
- *
3456
- * open('myfile', 'wx', (err, fd) => {
3457
- * if (err) {
3458
- * if (err.code === 'EEXIST') {
3459
- * console.error('myfile already exists');
3460
- * return;
3461
- * }
3462
- *
3463
- * throw err;
3464
- * }
3465
- *
3466
- * try {
3467
- * writeMyData(fd);
3468
- * } finally {
3469
- * close(fd, (err) => {
3470
- * if (err) throw err;
3471
- * });
3472
- * }
3473
- * });
3474
- * ```
3475
- *
3476
- * **read (NOT RECOMMENDED)**
3477
- *
3478
- * ```js
3479
- * import { access, open, close } from 'node:fs';
3480
- * access('myfile', (err) => {
3481
- * if (err) {
3482
- * if (err.code === 'ENOENT') {
3483
- * console.error('myfile does not exist');
3484
- * return;
3485
- * }
3486
- *
3487
- * throw err;
3488
- * }
3489
- *
3490
- * open('myfile', 'r', (err, fd) => {
3491
- * if (err) throw err;
3492
- *
3493
- * try {
3494
- * readMyData(fd);
3495
- * } finally {
3496
- * close(fd, (err) => {
3497
- * if (err) throw err;
3498
- * });
3499
- * }
3500
- * });
3501
- * });
3502
- * ```
3503
- *
3504
- * **read (RECOMMENDED)**
3505
- *
3506
- * ```js
3507
- * import { open, close } from 'node:fs';
3508
- *
3509
- * open('myfile', 'r', (err, fd) => {
3510
- * if (err) {
3511
- * if (err.code === 'ENOENT') {
3512
- * console.error('myfile does not exist');
3513
- * return;
3514
- * }
3515
- *
3516
- * throw err;
3517
- * }
3518
- *
3519
- * try {
3520
- * readMyData(fd);
3521
- * } finally {
3522
- * close(fd, (err) => {
3523
- * if (err) throw err;
3524
- * });
3525
- * }
3526
- * });
3527
- * ```
3528
- *
3529
- * The "not recommended" examples above check for accessibility and then use the
3530
- * file; the "recommended" examples are better because they use the file directly
3531
- * and handle the error, if any.
3532
- *
3533
- * In general, check for the accessibility of a file only if the file will not be
3534
- * used directly, for example when its accessibility is a signal from another
3535
- * process.
3536
- *
3537
- * On Windows, access-control policies (ACLs) on a directory may limit access to
3538
- * a file or directory. The `fs.access()` function, however, does not check the
3539
- * ACL and therefore may report that a path is accessible even if the ACL restricts
3540
- * the user from reading or writing to it.
3541
- * @since v0.11.15
3542
- * @param [mode=fs.constants.F_OK]
3543
- */
3544
- export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
3545
- /**
3546
- * Asynchronously tests a user's permissions for the file specified by path.
3547
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3548
- */
3549
- export function access(path: PathLike, callback: NoParamCallback): void;
3550
- export namespace access {
3551
- /**
3552
- * Asynchronously tests a user's permissions for the file specified by path.
3553
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3554
- * URL support is _experimental_.
3555
- */
3556
- function __promisify__(path: PathLike, mode?: number): Promise<void>;
3557
- }
3558
- /**
3559
- * Synchronously tests a user's permissions for the file or directory specified
3560
- * by `path`. The `mode` argument is an optional integer that specifies the
3561
- * accessibility checks to be performed. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and
3562
- * `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
3563
- * possible values of `mode`.
3564
- *
3565
- * If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
3566
- * the method will return `undefined`.
3567
- *
3568
- * ```js
3569
- * import { accessSync, constants } from 'node:fs';
3570
- *
3571
- * try {
3572
- * accessSync('etc/passwd', constants.R_OK | constants.W_OK);
3573
- * console.log('can read/write');
3574
- * } catch (err) {
3575
- * console.error('no access!');
3576
- * }
3577
- * ```
3578
- * @since v0.11.15
3579
- * @param [mode=fs.constants.F_OK]
3580
- */
3581
- export function accessSync(path: PathLike, mode?: number): void;
3582
- interface StreamOptions {
3583
- flags?: string | undefined;
3584
- encoding?: BufferEncoding | undefined;
3585
- fd?: number | promises.FileHandle | undefined;
3586
- mode?: number | undefined;
3587
- autoClose?: boolean | undefined;
3588
- /**
3589
- * @default false
3590
- */
3591
- emitClose?: boolean | undefined;
3592
- start?: number | undefined;
3593
- highWaterMark?: number | undefined;
3594
- }
3595
- interface ReadStreamOptions extends StreamOptions {
3596
- end?: number | undefined;
3597
- }
3598
- /**
3599
- * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
3600
- * returned by this method has a default `highWaterMark` of 64 KiB.
3601
- *
3602
- * `options` can include `start` and `end` values to read a range of bytes from
3603
- * the file instead of the entire file. Both `start` and `end` are inclusive and
3604
- * start counting at 0, allowed values are in the
3605
- * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is
3606
- * omitted or `undefined`, `fs.createReadStream()` reads sequentially from the
3607
- * current file position. The `encoding` can be any one of those accepted by `Buffer`.
3608
- *
3609
- * If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
3610
- * the specified file descriptor. This means that no `'open'` event will be
3611
- * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`.
3612
- *
3613
- * If `fd` points to a character device that only supports blocking reads
3614
- * (such as keyboard or sound card), read operations do not finish until data is
3615
- * available. This can prevent the process from exiting and the stream from
3616
- * closing naturally.
3617
- *
3618
- * By default, the stream will emit a `'close'` event after it has been
3619
- * destroyed. Set the `emitClose` option to `false` to change this behavior.
3620
- *
3621
- * By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option,
3622
- * an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is
3623
- * also required.
3624
- *
3625
- * ```js
3626
- * import { createReadStream } from 'node:fs';
3627
- *
3628
- * // Create a stream from some character device.
3629
- * const stream = createReadStream('/dev/input/event0');
3630
- * setTimeout(() => {
3631
- * stream.close(); // This may not close the stream.
3632
- * // Artificially marking end-of-stream, as if the underlying resource had
3633
- * // indicated end-of-file by itself, allows the stream to close.
3634
- * // This does not cancel pending read operations, and if there is such an
3635
- * // operation, the process may still not be able to exit successfully
3636
- * // until it finishes.
3637
- * stream.push(null);
3638
- * stream.read(0);
3639
- * }, 100);
3640
- * ```
3641
- *
3642
- * If `autoClose` is false, then the file descriptor won't be closed, even if
3643
- * there's an error. It is the application's responsibility to close it and make
3644
- * sure there's no file descriptor leak. If `autoClose` is set to true (default
3645
- * behavior), on `'error'` or `'end'` the file descriptor will be closed
3646
- * automatically.
3647
- *
3648
- * `mode` sets the file mode (permission and sticky bits), but only if the
3649
- * file was created.
3650
- *
3651
- * An example to read the last 10 bytes of a file which is 100 bytes long:
3652
- *
3653
- * ```js
3654
- * import { createReadStream } from 'node:fs';
3655
- *
3656
- * createReadStream('sample.txt', { start: 90, end: 99 });
3657
- * ```
3658
- *
3659
- * If `options` is a string, then it specifies the encoding.
3660
- * @since v0.1.31
3661
- */
3662
- export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
3663
- /**
3664
- * `options` may also include a `start` option to allow writing data at some
3665
- * position past the beginning of the file, allowed values are in the
3666
- * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
3667
- * replacing it may require the `flags` option to be set to `r+` rather than the
3668
- * default `w`. The `encoding` can be any one of those accepted by `Buffer`.
3669
- *
3670
- * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
3671
- * then the file descriptor won't be closed, even if there's an error.
3672
- * It is the application's responsibility to close it and make sure there's no
3673
- * file descriptor leak.
3674
- *
3675
- * By default, the stream will emit a `'close'` event after it has been
3676
- * destroyed. Set the `emitClose` option to `false` to change this behavior.
3677
- *
3678
- * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce
3679
- * performance as some optimizations (`_writev()`)
3680
- * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override
3681
- * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required.
3682
- *
3683
- * Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
3684
- * emitted. `fd` should be blocking; non-blocking `fd`s
3685
- * should be passed to `net.Socket`.
3686
- *
3687
- * If `options` is a string, then it specifies the encoding.
3688
- * @since v0.1.31
3689
- */
3690
- export function createWriteStream(path: PathLike, options?: BufferEncoding | StreamOptions): WriteStream;
3691
- /**
3692
- * Forces all currently queued I/O operations associated with the file to the
3693
- * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other
3694
- * than a possible
3695
- * exception are given to the completion callback.
3696
- * @since v0.1.96
3697
- */
3698
- export function fdatasync(fd: number, callback: NoParamCallback): void;
3699
- export namespace fdatasync {
3700
- /**
3701
- * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
3702
- * @param fd A file descriptor.
3703
- */
3704
- function __promisify__(fd: number): Promise<void>;
3705
- }
3706
- /**
3707
- * Forces all currently queued I/O operations associated with the file to the
3708
- * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. Returns `undefined`.
3709
- * @since v0.1.96
3710
- */
3711
- export function fdatasyncSync(fd: number): void;
3712
- /**
3713
- * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
3714
- * already exists. No arguments other than a possible exception are given to the
3715
- * callback function. Node.js makes no guarantees about the atomicity of the copy
3716
- * operation. If an error occurs after the destination file has been opened for
3717
- * writing, Node.js will attempt to remove the destination.
3718
- *
3719
- * `mode` is an optional integer that specifies the behavior
3720
- * of the copy operation. It is possible to create a mask consisting of the bitwise
3721
- * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
3722
- *
3723
- * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
3724
- * exists.
3725
- * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
3726
- * copy-on-write reflink. If the platform does not support copy-on-write, then a
3727
- * fallback copy mechanism is used.
3728
- * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
3729
- * create a copy-on-write reflink. If the platform does not support
3730
- * copy-on-write, then the operation will fail.
3731
- *
3732
- * ```js
3733
- * import { copyFile, constants } from 'node:fs';
3734
- *
3735
- * function callback(err) {
3736
- * if (err) throw err;
3737
- * console.log('source.txt was copied to destination.txt');
3738
- * }
3739
- *
3740
- * // destination.txt will be created or overwritten by default.
3741
- * copyFile('source.txt', 'destination.txt', callback);
3742
- *
3743
- * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
3744
- * copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);
3745
- * ```
3746
- * @since v8.5.0
3747
- * @param src source filename to copy
3748
- * @param dest destination filename of the copy operation
3749
- * @param [mode=0] modifiers for copy operation.
3750
- */
3751
- export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
3752
- export function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void;
3753
- export namespace copyFile {
3754
- function __promisify__(src: PathLike, dst: PathLike, mode?: number): Promise<void>;
3755
- }
3756
- /**
3757
- * Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it
3758
- * already exists. Returns `undefined`. Node.js makes no guarantees about the
3759
- * atomicity of the copy operation. If an error occurs after the destination file
3760
- * has been opened for writing, Node.js will attempt to remove the destination.
3761
- *
3762
- * `mode` is an optional integer that specifies the behavior
3763
- * of the copy operation. It is possible to create a mask consisting of the bitwise
3764
- * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
3765
- *
3766
- * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
3767
- * exists.
3768
- * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
3769
- * copy-on-write reflink. If the platform does not support copy-on-write, then a
3770
- * fallback copy mechanism is used.
3771
- * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
3772
- * create a copy-on-write reflink. If the platform does not support
3773
- * copy-on-write, then the operation will fail.
3774
- *
3775
- * ```js
3776
- * import { copyFileSync, constants } from 'node:fs';
3777
- *
3778
- * // destination.txt will be created or overwritten by default.
3779
- * copyFileSync('source.txt', 'destination.txt');
3780
- * console.log('source.txt was copied to destination.txt');
3781
- *
3782
- * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
3783
- * copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
3784
- * ```
3785
- * @since v8.5.0
3786
- * @param src source filename to copy
3787
- * @param dest destination filename of the copy operation
3788
- * @param [mode=0] modifiers for copy operation.
3789
- */
3790
- export function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
3791
- /**
3792
- * Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`.
3793
- *
3794
- * `position` is the offset from the beginning of the file where this data
3795
- * should be written. If `typeof position !== 'number'`, the data will be written
3796
- * at the current position.
3797
- *
3798
- * The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`.
3799
- *
3800
- * If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties.
3801
- *
3802
- * It is unsafe to use `fs.writev()` multiple times on the same file without
3803
- * waiting for the callback. For this scenario, use {@link createWriteStream}.
3804
- *
3805
- * On Linux, positional writes don't work when the file is opened in append mode.
3806
- * The kernel ignores the position argument and always appends the data to
3807
- * the end of the file.
3808
- * @since v12.9.0
3809
- * @param [position='null']
3810
- */
3811
- export function writev(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
3812
- export function writev(
3813
- fd: number,
3814
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
3815
- position: number,
3816
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
3817
- ): void;
3818
- export interface WriteVResult {
3819
- bytesWritten: number;
3820
- buffers: NodeJS.ArrayBufferView[];
3821
- }
3822
- export namespace writev {
3823
- function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
3824
- }
3825
- /**
3826
- * For detailed information, see the documentation of the asynchronous version of
3827
- * this API: {@link writev}.
3828
- * @since v12.9.0
3829
- * @param [position='null']
3830
- * @return The number of bytes written.
3831
- */
3832
- export function writevSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3833
- /**
3834
- * Read from a file specified by `fd` and write to an array of `ArrayBufferView`s
3835
- * using `readv()`.
3836
- *
3837
- * `position` is the offset from the beginning of the file from where data
3838
- * should be read. If `typeof position !== 'number'`, the data will be read
3839
- * from the current position.
3840
- *
3841
- * The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file.
3842
- *
3843
- * If this method is invoked as its `util.promisify()` ed version, it returns
3844
- * a promise for an `Object` with `bytesRead` and `buffers` properties.
3845
- * @since v13.13.0, v12.17.0
3846
- * @param [position='null']
3847
- */
3848
- export function readv(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
3849
- export function readv(
3850
- fd: number,
3851
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
3852
- position: number,
3853
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
3854
- ): void;
3855
- export interface ReadVResult {
3856
- bytesRead: number;
3857
- buffers: NodeJS.ArrayBufferView[];
3858
- }
3859
- export namespace readv {
3860
- function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
3861
- }
3862
- /**
3863
- * For detailed information, see the documentation of the asynchronous version of
3864
- * this API: {@link readv}.
3865
- * @since v13.13.0, v12.17.0
3866
- * @param [position='null']
3867
- * @return The number of bytes read.
3868
- */
3869
- export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3870
- export interface OpenDirOptions {
3871
- /**
3872
- * @default 'utf8'
3873
- */
3874
- encoding?: BufferEncoding | undefined;
3875
- /**
3876
- * Number of directory entries that are buffered
3877
- * internally when reading from the directory. Higher values lead to better
3878
- * performance but higher memory usage.
3879
- * @default 32
3880
- */
3881
- bufferSize?: number | undefined;
3882
- /**
3883
- * @default false
3884
- */
3885
- recursive?: boolean;
3886
- }
3887
- /**
3888
- * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
3889
- *
3890
- * Creates an `fs.Dir`, which contains all further functions for reading from
3891
- * and cleaning up the directory.
3892
- *
3893
- * The `encoding` option sets the encoding for the `path` while opening the
3894
- * directory and subsequent read operations.
3895
- * @since v12.12.0
3896
- */
3897
- export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir;
3898
- /**
3899
- * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
3900
- * more details.
3901
- *
3902
- * Creates an `fs.Dir`, which contains all further functions for reading from
3903
- * and cleaning up the directory.
3904
- *
3905
- * The `encoding` option sets the encoding for the `path` while opening the
3906
- * directory and subsequent read operations.
3907
- * @since v12.12.0
3908
- */
3909
- export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3910
- export function opendir(path: PathLike, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3911
- export namespace opendir {
3912
- function __promisify__(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
3913
- }
3914
- export interface BigIntStats extends StatsBase<bigint> {
3915
- atimeNs: bigint;
3916
- mtimeNs: bigint;
3917
- ctimeNs: bigint;
3918
- birthtimeNs: bigint;
3919
- }
3920
- export interface BigIntOptions {
3921
- bigint: true;
3922
- }
3923
- export interface StatOptions {
3924
- bigint?: boolean | undefined;
3925
- }
3926
- export interface StatSyncOptions extends StatOptions {
3927
- throwIfNoEntry?: boolean | undefined;
3928
- }
3929
- interface CopyOptionsBase {
3930
- /**
3931
- * Dereference symlinks
3932
- * @default false
3933
- */
3934
- dereference?: boolean;
3935
- /**
3936
- * When `force` is `false`, and the destination
3937
- * exists, throw an error.
3938
- * @default false
3939
- */
3940
- errorOnExist?: boolean;
3941
- /**
3942
- * Overwrite existing file or directory. _The copy
3943
- * operation will ignore errors if you set this to false and the destination
3944
- * exists. Use the `errorOnExist` option to change this behavior.
3945
- * @default true
3946
- */
3947
- force?: boolean;
3948
- /**
3949
- * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
3950
- */
3951
- mode?: number;
3952
- /**
3953
- * When `true` timestamps from `src` will
3954
- * be preserved.
3955
- * @default false
3956
- */
3957
- preserveTimestamps?: boolean;
3958
- /**
3959
- * Copy directories recursively.
3960
- * @default false
3961
- */
3962
- recursive?: boolean;
3963
- /**
3964
- * When true, path resolution for symlinks will be skipped
3965
- * @default false
3966
- */
3967
- verbatimSymlinks?: boolean;
3968
- }
3969
- export interface CopyOptions extends CopyOptionsBase {
3970
- /**
3971
- * Function to filter copied files/directories. Return
3972
- * `true` to copy the item, `false` to ignore it.
3973
- */
3974
- filter?(source: string, destination: string): boolean | Promise<boolean>;
3975
- }
3976
- export interface CopySyncOptions extends CopyOptionsBase {
3977
- /**
3978
- * Function to filter copied files/directories. Return
3979
- * `true` to copy the item, `false` to ignore it.
3980
- */
3981
- filter?(source: string, destination: string): boolean;
3982
- }
3983
- /**
3984
- * Asynchronously copies the entire directory structure from `src` to `dest`,
3985
- * including subdirectories and files.
3986
- *
3987
- * When copying a directory to another directory, globs are not supported and
3988
- * behavior is similar to `cp dir1/ dir2/`.
3989
- * @since v16.7.0
3990
- * @experimental
3991
- * @param src source path to copy.
3992
- * @param dest destination path to copy to.
3993
- */
3994
- export function cp(source: string | URL, destination: string | URL, callback: (err: NodeJS.ErrnoException | null) => void): void;
3995
- export function cp(source: string | URL, destination: string | URL, opts: CopyOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
3996
- /**
3997
- * Synchronously copies the entire directory structure from `src` to `dest`,
3998
- * including subdirectories and files.
3999
- *
4000
- * When copying a directory to another directory, globs are not supported and
4001
- * behavior is similar to `cp dir1/ dir2/`.
4002
- * @since v16.7.0
4003
- * @experimental
4004
- * @param src source path to copy.
4005
- * @param dest destination path to copy to.
4006
- */
4007
- export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
4008
- }
4009
- declare module 'node:fs' {
4010
- export * from 'fs';
4011
- }