Socket
Socket
Sign inDemoInstall

bilderhic

Package Overview
Dependencies
73
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.3.1

test/files/config-2.xml

2

package.json
{
"name": "bilderhic",
"version": " 1.3.0",
"version": " 1.3.1",
"description": "Bilderhic (bhic) is a smart and simple command tool for automatization.",

@@ -5,0 +5,0 @@ "preferGlobal": true,

@@ -33,3 +33,3 @@ /* eslint-disable no-await-in-loop */

if (final[0] === "-") {
final = final.substr(1).trimLeft();
final = final.substring(1).trimStart();
}

@@ -67,3 +67,8 @@

else if (cmd === "save") {
editor.save();
if (line && line.trim()) {
editor.save(this.parsePath(line));
}
else {
editor.save();
}
}

@@ -70,0 +75,0 @@ else if (editor.isObjectEditor) {

@@ -9,2 +9,4 @@ const fs = require("fs");

format: true,
// attributeNamePrefix: "@_",
// preserveOrder: true,
};

@@ -30,4 +32,4 @@

if (content.indexOf("<?xml") !== -1) {
this.declaration = content.substr(content.indexOf("<?xml"));
if (content.includes("<?xml")) {
this.declaration = content.substring(content.indexOf("<?xml"));
this.declaration = this.declaration.substr(0, this.declaration.indexOf(">") + 1);

@@ -168,4 +170,9 @@ }

serialize() {
const builder = new XMLBuilder();
const finalContent = this.declaration + builder.build(this.object);
const builder = new XMLBuilder({
format: this.options.format,
// preserveOrder: true,
ignoreAttributes: false,
attributeNamePrefix: "@_",
});
const finalContent = builder.build(this.object).trim();
return finalContent;

@@ -172,0 +179,0 @@ }

@@ -54,2 +54,44 @@ const fs = require("fs");

});
it("save-as should work fine", async () => {
const finalPath = path.join(folder, "./files", "json-file.json.txt");
try {
const result = await cmd.run(["json-file.json", "txt", " - save json-file.json.txt", "- close"]);
expect(result).to.eq(0);
expect(fs.existsSync(finalPath)).to.be.true;
}
finally {
if (fs.existsSync(finalPath)) {
fs.rmSync(finalPath);
}
}
});
it("xml using xml editor", async () => {
const result = await cmd.run(["config.xml", "xml", "- close"]);
expect(result).to.eq(0);
});
it("xml should work fine", async () => {
const configPath = path.join(folder, "./files", "config.xml");
const config2Path = path.join(folder, "./files", "config-2.xml");
try {
const result = await cmd.run(["config.xml", "xml", " -save config-2.xml", "- close"]);
expect(result).to.eq(0);
expect(fs.existsSync(configPath)).to.be.true;
expect(fs.existsSync(config2Path)).to.be.true;
// const content1 = fs.readFileSync(configPath, "utf-8");
const content2 = fs.readFileSync(config2Path, "utf-8");
expect(content2.includes("@_")).to.be.false;
}
finally {
if (fs.existsSync(config2Path)) {
// fs.rmSync(config2Path);
}
}
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc