Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@haibun/core

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haibun/core - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

27

build/lib/features.test.js

@@ -24,2 +24,3 @@ "use strict";

const TestSteps_1 = require("./TestSteps");
const util_1 = require("./util");
describe('expandBackgrounds', () => {

@@ -88,3 +89,3 @@ test('simple', async () => {

xdescribe('expand features', () => {
test.only('applies backgrounds', async () => {
test('applies backgrounds', async () => {
const features = TestSteps_1.asFeatures([{ path: '/f1', content: 'Backgrounds: b1\nextant' }]);

@@ -106,2 +107,26 @@ const backgrounds = TestSteps_1.asFeatures([{ path: '/b1.feature', content: 'result' }]);

});
describe('env vars', () => {
it('rotates ENVC vars', async () => {
let index = 0;
const TestEnvcStepper = class TestRoute {
constructor(world) {
this.steps = {
addRoute: {
gwta: 'finds a {what}',
action: async ({ what }) => {
expect(what).toBe(index);
index++;
return util_1.actionOK();
},
},
};
this.world = world;
}
};
const feature = { path: '/features/test.feature', content: `\nfinds a {what}\nfinds a {what}` };
const env = { what: [0, 1] };
const { world } = await TestSteps_1.testWithDefaults([feature], [TestEnvcStepper], { env });
expect(world.options._index_what).toBe(1);
});
});
//# sourceMappingURL=features.test.js.map

@@ -99,7 +99,20 @@ "use strict";

// FIXME add test
const val = process.env[namedValue];
if (!val) {
const val = world.options.env[namedValue];
console.log('v', val);
if (val === undefined) {
throw Error(`no env value for "${namedValue}" from ${JSON.stringify({ shared, type })}`);
}
namedFromVars[name] = val;
if (Array.isArray(val)) {
let index = world.options[`_index_${namedValue}`] === undefined ? val.length - 1 : world.options[`_index_${namedValue}`];
index++;
if (index > val.length - 1) {
index = 0;
}
console.log('ww', val[index], index);
world.options[`_index_${namedValue}`] = index;
namedFromVars[name] = val[index];
}
else {
namedFromVars[name] = val;
}
}

@@ -106,0 +119,0 @@ else if (namedKey.startsWith(TYPE_QUOTED)) {

@@ -92,2 +92,4 @@ "use strict";

});
describe('getEnv', () => {
});
//# sourceMappingURL=namedVars.test.js.map

@@ -17,2 +17,3 @@ import { IStepper, IExtensionConstructor, TWorld, TVStep, TProtoOptions, TOptions } from './defs';

steppers?: IStepper[] | undefined;
world: TWorld;
}>;

@@ -19,0 +20,0 @@ export declare function testRun(baseIn: string, addSteppers: IExtensionConstructor[], world: TWorld, protoOptions?: TProtoOptions): Promise<{

2

build/lib/TestSteps.js

@@ -110,3 +110,3 @@ "use strict";

const features = exports.asFeatures(these);
return await run_1.runWith({ specl, features, backgrounds: [], addSteppers, world });
return { world, ...await run_1.runWith({ specl, features, backgrounds: [], addSteppers, world }) };
}

@@ -113,0 +113,0 @@ exports.testWithDefaults = testWithDefaults;

@@ -38,2 +38,3 @@ import { WorldContext } from './contexts';

};
export declare function applyEnvCollections(value: string, protoOptions: TProtoOptions): void;
export declare function applyExtraOptions(protoOptions: TProtoOptions, steppers: IStepper[], world: TWorld): void;

@@ -40,0 +41,0 @@ export declare function getStepperOptions(key: string, value: string, steppers: (IStepper & IHasOptions)[]): TOptionValue | void;

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.applyResShouldContinue = exports.getFromRuntime = exports.getStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.applyExtraOptions = exports.processEnv = exports.getDefaultWorld = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0;
exports.applyResShouldContinue = exports.getFromRuntime = exports.getStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.applyExtraOptions = exports.applyEnvCollections = exports.processEnv = exports.getDefaultWorld = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0;
const fs_1 = require("fs");

@@ -185,3 +185,3 @@ const path_1 = __importDefault(require("path"));

function processEnv(env, options) {
const protoOptions = { options: { ...options }, extraOptions: {} };
const protoOptions = { options: { ...options, env: {} }, extraOptions: {} };
let errors = [];

@@ -222,2 +222,15 @@ const pfx = `${defs_1.HAIBUN}_`;

}
else if (opt === 'ENV') {
const pairs = value?.split(',');
for (const pair in pairs) {
const [k, v] = pair.split(',').map(i => i.trim());
if (protoOptions.options.env[k]) {
throw Error(`ENV ${k} already exists`);
}
protoOptions.options.env[k] = v;
}
}
else if (opt === 'ENVC') {
applyEnvCollections(value, protoOptions);
}
else {

@@ -230,2 +243,17 @@ protoOptions.extraOptions[k] = value;

exports.processEnv = processEnv;
function applyEnvCollections(value, protoOptions) {
const pairs = new Set(value?.split(',').map(a => a.split('=')[0]));
for (const pair of pairs) {
const [k] = Array.from(new Set(pair.split('=')));
if (protoOptions.options.env[k]) {
throw Error(`ENVC ${k} already exists`);
}
protoOptions.options.env[k] = [];
}
for (const pair of value?.split(',')) {
const [k, v] = pair.split('=');
protoOptions.options.env[k].push(v);
}
}
exports.applyEnvCollections = applyEnvCollections;
// has side effects

@@ -232,0 +260,0 @@ function applyExtraOptions(protoOptions, steppers, world) {

@@ -95,2 +95,16 @@ "use strict";

});
describe('applyEnvCollections', () => {
it('creates pairs', () => {
const p = { options: { env: {} }, extraOptions: {} };
util.applyEnvCollections('a=1,b=2,a=3,b=4', p);
expect(p.options.env).toEqual({
a: ["1", "3"],
b: ["2", "4"]
});
});
it('prevents collision', () => {
const p = { options: { env: { a: 1 } }, extraOptions: {} };
expect(() => util.applyEnvCollections('a=1', p)).toThrow();
});
});
//# sourceMappingURL=util.test.js.map

@@ -50,5 +50,5 @@ "use strict";

display: {
gwta: 'display (?<what>.+)',
gwta: 'display {what}',
action: async ({ what }) => {
this.world.logger.log(`${what} is ${this.world.shared.get(what)}`);
this.world.logger.log(`is ${what}`);
return defs_1.OK;

@@ -55,0 +55,0 @@ },

{
"name": "@haibun/core",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -5,0 +5,0 @@ "author": "",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc