@lvce-editor/search-process 0.28.0 → 0.28.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/search-process",
3
- "version": "0.28.0",
3
+ "version": "0.28.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -20,10 +20,8 @@
20
20
  "@lvce-editor/assert": "^1.2.0",
21
21
  "@lvce-editor/ipc": "^8.2.0",
22
22
  "@lvce-editor/json-rpc": "^1.3.0",
23
+ "@lvce-editor/ripgrep": "^1.1.0",
23
24
  "@lvce-editor/verror": "^1.2.0",
24
25
  "execa": "^8.0.1"
25
- },
26
- "optionalDependencies": {
27
- "@lvce-editor/ripgrep": "^1.1.0"
28
26
  }
29
27
  }
@@ -0,0 +1,22 @@
1
+ import * as fs from 'node:fs/promises'
2
+ import * as Assert from '../Assert/Assert.js'
3
+ import * as EncodingType from '../EncodingType/EncodingType.js'
4
+ import { VError } from '../VError/VError.js'
5
+
6
+ /**
7
+ *
8
+ * @param {string} path
9
+ * @param {string} content
10
+ * @param {BufferEncoding} encoding
11
+ */
12
+ export const writeFile = async (path, content, encoding = EncodingType.Utf8) => {
13
+ try {
14
+ Assert.string(path)
15
+ Assert.string(content)
16
+ // queue would be more correct for concurrent writes but also slower
17
+ // Queue.add(`writeFile/${path}`, () =>
18
+ await fs.writeFile(path, content, encoding)
19
+ } catch (error) {
20
+ throw new VError(error, `Failed to write to file "${path}"`)
21
+ }
22
+ }