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.1.1 to 1.1.2

7

index.js

@@ -10,2 +10,3 @@ #!/usr/bin/env node

const moment = require("moment");
const Environment = require("./src/environment");

@@ -24,3 +25,7 @@ const Pipe = require("./src/commands/pipe/index");

const initialVariables = {};
const initialVariables = {
timestamp: () => moment().format("YYYYMMDDHHmmss"),
date: format => moment().format(format ? format[0] : "YYYY-MM-DD"),
time: format => moment().format(format ? format[0] : "HHmmss"),
};

@@ -27,0 +32,0 @@ for (let i = 0; i < args.length; i++) {

13

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

@@ -59,8 +59,8 @@ "preferGlobal": true,

"devDependencies": {
"chai": "^4.2.0",
"eslint": "^7.11.0",
"chai": "^4.3.4",
"eslint": "^7.25.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-import": "^2.22.1",
"mocha": "^8.2.0",
"mocha": "^8.3.2",
"nyc": "^15.1.0"

@@ -74,7 +74,8 @@ },

"glob": "^7.1.6",
"inquirer": "^7.3.3",
"inquirer": "^8.0.0",
"md5-file": "^5.0.0",
"moment": "^2.29.1",
"safe-eval": "git+https://github.com/hacksparrow/safe-eval.git",
"yaml": "^1.7.2"
}
}
}

@@ -392,1 +392,26 @@ <img src="https://lucianorasente.com/public_img/bhic.png" style="max-width:100px;width:100%;">

```
Timestamp
```bash
bhic -c echo My timestamp is [timestamp]
```
Date
```bash
bhic -c echo Today is [date]
```
Date (custom format)
```bash
bhic -c echo Today is [date:YYYY-MM-DD]
```
Time
```bash
bhic -c echo The current time is [hour]
```
Time (custom format)
```bash
bhic -c echo The current time is [hour:HH.MM]
```

@@ -0,3 +1,6 @@

/* eslint-disable class-methods-use-this */
/** @typedef {import("../../environment")} Environment */
const os = require('os');
const os = require("os");
const path = require("path");

@@ -4,0 +7,0 @@ const inquirer = require("inquirer");

@@ -102,3 +102,3 @@ const path = require("path");

if (typeof existing === "undefined") {
this.variables[id] = value;
this.setVariable(id, value);
}

@@ -115,4 +115,6 @@ }

Object.keys(this.variables).forEach(k => {
if (typeof this.variables[k] === "object") {
extractVariables(this.variables[k], k).forEach(kv => {
const variable = this.variables[k];
if (typeof variable === "object") {
extractVariables(variable, k).forEach(kv => {
variables[kv.key] = kv.value;

@@ -158,5 +160,27 @@ });

Object.keys(variables).forEach(key => {
while (finalStr.indexOf(`[${key}]`) !== -1) {
const val = variables[key];
finalStr = finalStr.replace(`[${key}]`, `${val}`);
while (finalStr.includes(`[${key}]`) || finalStr.includes(`[${key}:`)) {
let args = null;
let keyWithArgs;
if (finalStr.includes(`[${key}:`)) {
args = finalStr.substr(finalStr.indexOf(`[${key}:`));
args = args.substring(args.indexOf(":") + 1, args.indexOf("]"));
keyWithArgs = `${key}:${args}`;
}
else {
keyWithArgs = key;
}
let val = variables[key];
if (typeof variables[key] === "function") {
if (args) {
val = val(args);
}
else {
val = val();
}
}
finalStr = finalStr.replace(`[${keyWithArgs}]`, `${val}`);
}

@@ -163,0 +187,0 @@ });

@@ -107,3 +107,10 @@ const { expect } = require("chai");

});
it("should work fine - env set example", () => {
const line = "env set hola \"hola mundo\"";
const expected = ["env", "set","hola", "hola mundo"];
const result = CommandsExtractor.extract(line);
expect(result).deep.equals(expected);
});
});
});

@@ -152,3 +152,19 @@ const { expect } = require("chai");

});
it("apply a function variable", () => {
env.setVariable("test", () => "testVar");
const path = "[test].ok";
const result = env.applyVariables(path);
const expected = "testVar.ok";
expect(result).to.equals(expected);
});
it("apply a function variable with parameters", () => {
env.setVariable("test", x => `testVar${x}`);
const path = "[test:iable].ok";
const result = env.applyVariables(path);
const expected = "testVariable.ok";
expect(result).to.equals(expected);
});
});
});
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