inibase 1.0.0-rc.119 → 1.0.0-rc.120

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 (2) hide show
  1. package/dist/file.js +12 -12
  2. package/package.json +1 -1
package/dist/file.js CHANGED
@@ -40,7 +40,7 @@ export function escapeShellPath(filePath) {
40
40
  // Resolve the path to avoid relative path issues
41
41
  const resolvedPath = resolve(filePath);
42
42
  // Escape double quotes and special shell characters
43
- return resolvedPath.replace(/(["\\$`])/g, "\\$1");
43
+ return `"${resolvedPath.replace(/(["\\$`])/g, "\\$1")}"`;
44
44
  }
45
45
  const _pipeline = async (filePath, rl, writeStream, transform) => {
46
46
  if (filePath.endsWith(".gz"))
@@ -223,7 +223,7 @@ export async function get(filePath, lineNumbers, fieldType, fieldChildrenType, s
223
223
  }
224
224
  }
225
225
  else if (lineNumbers == -1) {
226
- const escapedFilePath = `${escapeShellPath(filePath)}`;
226
+ const escapedFilePath = escapeShellPath(filePath);
227
227
  const command = filePath.endsWith(".gz")
228
228
  ? `zcat ${escapedFilePath} | sed -n '$p'`
229
229
  : `sed -n '$p' ${escapedFilePath}`, foundedLine = (await exec(command)).stdout.trimEnd();
@@ -245,10 +245,10 @@ export async function get(filePath, lineNumbers, fieldType, fieldChildrenType, s
245
245
  }
246
246
  return [lines, linesCount];
247
247
  }
248
- const escapedFilePath = `${escapeShellPath(filePath)}`;
248
+ const escapedFilePath = escapeShellPath(filePath);
249
249
  const command = filePath.endsWith(".gz")
250
- ? `zcat "${escapedFilePath}" | sed -n '${_groupIntoRanges(lineNumbers)}'`
251
- : `sed -n '${_groupIntoRanges(lineNumbers)}' "${escapedFilePath}"`, foundedLines = (await exec(command)).stdout.trimEnd().split("\n");
250
+ ? `zcat ${escapedFilePath} | sed -n '${_groupIntoRanges(lineNumbers)}'`
251
+ : `sed -n '${_groupIntoRanges(lineNumbers)}' ${escapedFilePath}`, foundedLines = (await exec(command)).stdout.trimEnd().split("\n");
252
252
  let index = 0;
253
253
  for (const line of foundedLines) {
254
254
  lines[lineNumbers[index]] = decode(line, fieldType, fieldChildrenType, secretKey);
@@ -398,7 +398,7 @@ export const append = async (filePath, data) => {
398
398
  await appendFile(fileTempPath, `${Array.isArray(data) ? data.join("\n") : data}\n`);
399
399
  }
400
400
  else {
401
- const escapedFileTempPath = `${escapeShellPath(fileTempPath)}`;
401
+ const escapedFileTempPath = escapeShellPath(fileTempPath);
402
402
  await exec(`echo $'${(Array.isArray(data) ? data.join("\n") : data)
403
403
  .toString()
404
404
  .replace(/'/g, "\\'")}' | gzip - >> ${escapedFileTempPath}`);
@@ -454,9 +454,9 @@ export const prepend = async (filePath, data) => {
454
454
  const fileChildTempPath = filePath.replace(/([^/]+)\/?$/, ".tmp/tmp_$1");
455
455
  try {
456
456
  await write(fileChildTempPath, `${Array.isArray(data) ? data.join("\n") : data}\n`);
457
- const escapedFilePath = `${escapeShellPath(filePath)}`;
458
- const escapedFileTempPath = `${escapeShellPath(fileTempPath)}`;
459
- const escapedFileChildTempPath = `${escapeShellPath(fileChildTempPath)}`;
457
+ const escapedFilePath = escapeShellPath(filePath);
458
+ const escapedFileTempPath = escapeShellPath(fileTempPath);
459
+ const escapedFileChildTempPath = escapeShellPath(fileChildTempPath);
460
460
  await exec(`cat ${escapedFileChildTempPath} ${escapedFilePath} > ${escapedFileTempPath}`);
461
461
  }
462
462
  catch {
@@ -494,10 +494,10 @@ export const remove = async (filePath, linesToDelete) => {
494
494
  throw new Error("UNVALID_LINE_NUMBERS");
495
495
  const fileTempPath = filePath.replace(/([^/]+)\/?$/, ".tmp/$1");
496
496
  try {
497
- const escapedFilePath = `${escapeShellPath(filePath)}`;
498
- const escapedFileTempPath = `${escapeShellPath(fileTempPath)}`;
497
+ const escapedFilePath = escapeShellPath(filePath);
498
+ const escapedFileTempPath = escapeShellPath(fileTempPath);
499
499
  const command = filePath.endsWith(".gz")
500
- ? `zcat ${escapedFilePath} | sed '${_groupIntoRanges(linesToDelete, "d")}' | gzip > ${fileTempPath}`
500
+ ? `zcat ${escapedFilePath} | sed '${_groupIntoRanges(linesToDelete, "d")}' | gzip > ${escapedFileTempPath}`
501
501
  : `sed '${_groupIntoRanges(linesToDelete, "d")}' ${escapedFilePath} > ${escapedFileTempPath}`;
502
502
  await exec(command);
503
503
  return [fileTempPath, filePath];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.0.0-rc.119",
3
+ "version": "1.0.0-rc.120",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",