Socket
Socket
Sign inDemoInstall

@pact-foundation/pact-node

Package Overview
Dependencies
Maintainers
4
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pact-foundation/pact-node - npm Package Compare versions

Comparing version 10.2.2 to 10.2.3

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

## [10.2.3](https://github.com/pact-foundation/pact-node/compare/v10.2.2...v10.2.3) (2019-12-11)
### Bug Fixes
* **spawn:** Improve debug log formatting ([977a845](https://github.com/pact-foundation/pact-node/commit/977a845))
* **spawn:** Now binaries are spawned directly with array arguments, rather than quoted strings. Should fix [#118](https://github.com/pact-foundation/pact-node/issues/118) ([378f256](https://github.com/pact-foundation/pact-node/commit/378f256))
## [10.2.2](https://github.com/pact-foundation/pact-node/compare/v10.2.1...v10.2.2) (2019-11-15)

@@ -7,0 +17,0 @@

4

package.json
{
"name": "@pact-foundation/pact-node",
"version": "10.2.2",
"version": "10.2.3",
"description": "A wrapper for the Ruby version of Pact to work within Node",

@@ -59,2 +59,3 @@ "main": "src/index.js",

"check-types": "7.3.0",
"cross-spawn": "^7.0.1",
"decompress": "4.2.0",

@@ -78,2 +79,3 @@ "mkdirp": "0.5.1",

"@types/cors": "^2.8.6",
"@types/cross-spawn": "^6.0.1",
"@types/decompress": "^4.2.3",

@@ -80,0 +82,0 @@ "@types/express": "4.11.1",

@@ -86,3 +86,5 @@ "use strict";

var deferred = q.defer();
var instance = spawn_1.default.spawnBinary(pact_standalone_1.default.brokerPath + " can-i-deploy", CanDeploy.convertForSpawnBinary(this.options), this.__argMapping);
var instance = spawn_1.default.spawnBinary(pact_standalone_1.default.brokerPath, [
{ cliVerb: 'can-i-deploy' }
].concat(CanDeploy.convertForSpawnBinary(this.options)), this.__argMapping);
var output = [];

@@ -89,0 +91,0 @@ instance.stdout.on('data', function (l) { return output.push(l); });

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

var deferred = q.defer();
var instance = spawn_1.default.spawnBinary("" + pact_standalone_1.default.messagePath, this.options, this.__argMapping);
var instance = spawn_1.default.spawnBinary(pact_standalone_1.default.messagePath, this.options, this.__argMapping);
var output = [];

@@ -66,0 +66,0 @@ instance.stdout.on('data', function (l) { return output.push(l); });

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

var deferred = q.defer();
var instance = spawn_1.default.spawnBinary(pact_standalone_1.default.brokerPath + " publish", this.options, this.__argMapping);
var instance = spawn_1.default.spawnBinary(pact_standalone_1.default.brokerPath, [{ cliVerb: 'publish' }, this.options], this.__argMapping);
var output = [];

@@ -62,0 +62,0 @@ instance.stdout.on('data', function (l) { return output.push(l); });

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

}
_this = _super.call(this, pact_standalone_1.default.mockServicePath + " service", opts, {
_this = _super.call(this, pact_standalone_1.default.mockServicePath, opts, {
port: '--port',

@@ -94,3 +94,3 @@ host: '--host',

logLevel: '--log-level',
}) || this;
}, { cliVerb: 'service' }) || this;
return _this;

@@ -97,0 +97,0 @@ }

/// <reference types="node" />
import events = require('events');
import q = require('q');
import { CliVerbOptions } from './spawn';
import { ChildProcess } from 'child_process';

@@ -16,4 +17,5 @@ interface AbstractServiceEventInterface {

protected __instance: ChildProcess;
protected __cliVerb?: CliVerbOptions;
protected __serviceCommand: string;
protected constructor(command: string, options: ServiceOptions, argMapping: any);
protected constructor(command: string, options: ServiceOptions, argMapping: any, cliVerb?: CliVerbOptions);
start(): q.Promise<AbstractService>;

@@ -20,0 +22,0 @@ stop(): q.Promise<AbstractService>;

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

__extends(AbstractService, _super);
function AbstractService(command, options, argMapping) {
function AbstractService(command, options, argMapping, cliVerb) {
var _this = _super.call(this) || this;

@@ -85,2 +85,3 @@ options.ssl = options.ssl || false;

_this.__running = false;
_this.__cliVerb = cliVerb;
_this.__serviceCommand = command;

@@ -150,3 +151,3 @@ _this.__argMapping = argMapping;

AbstractService.prototype.spawnBinary = function () {
return spawn_1.default.spawnBinary(this.__serviceCommand, this.options, this.__argMapping);
return spawn_1.default.spawnBinary(this.__serviceCommand, this.__cliVerb ? [this.__cliVerb, this.options] : [this.options], this.__argMapping);
};

@@ -205,3 +206,3 @@ AbstractService.prototype.__waitForServiceUp = function () {

'Content-Type': 'application/json',
}
},
};

@@ -208,0 +209,0 @@ if (options.ssl) {

@@ -6,3 +6,7 @@ import { CanDeployOptions } from '../can-deploy';

import { VerifierOptions } from '../verifier';
export declare type SpawnArguments = CanDeployOptions[] | MessageOptions | PublisherOptions | ServiceOptions | VerifierOptions | {};
export declare type CliVerbOptions = {
cliVerb: string;
};
export declare type SpawnArgument = CanDeployOptions | MessageOptions | PublisherOptions | ServiceOptions | VerifierOptions | CliVerbOptions | {};
export declare type SpawnArguments = Array<SpawnArgument> | SpawnArgument;
export declare const DEFAULT_ARG = "DEFAULT";

@@ -9,0 +13,0 @@ export declare const PACT_NODE_NO_VALUE = "PACT_NODE_NO_VALUE";

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

var valFor = function (v) {
return v !== exports.PACT_NODE_NO_VALUE ? ["'" + v + "'"] : [];
return v !== exports.PACT_NODE_NO_VALUE ? [v] : [];
};

@@ -11,0 +11,0 @@ var mapFor = function (mapping, v) {

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

expect(result).to.include('--provider-base-url');
expect(result).to.include("'http://localhost'");
expect(result).to.include('http://localhost');
expect(result).to.include('--pact-urls');
expect(result).to.include("'http://idontexist'");
expect(result).to.include('http://idontexist');
});

@@ -44,3 +44,3 @@ });

});
it('should wrap its argument values in quotes', function () {
it('should produce correct arguments array', function () {
var result = arguments_1.default.toArgumentsArray([

@@ -56,9 +56,9 @@ {

expect(result).to.include('--provider-base-url');
expect(result).to.include("'http://localhost'");
expect(result).to.include('http://localhost');
expect(result).to.include('--pact-urls');
expect(result).to.include("'http://idontexist'");
expect(result).to.include('http://idontexist');
});
});
describe('with multiple elements', function () {
it('should wrap its argument values in quotes', function () {
it('should produce correct arguments array', function () {
var result = arguments_1.default.toArgumentsArray([

@@ -73,9 +73,9 @@ { participant: 'one' },

'--participant',
"'one'",
'one',
'--version',
"'v1'",
'v1',
'--participant',
"'two'",
'two',
'--version',
"'v2'",
'v2',
]);

@@ -94,3 +94,3 @@ });

expect(result.length).to.be.equal(3);
expect(result[0]).to.be.equal("'http://idontexist'");
expect(result[0]).to.be.equal('http://idontexist');
});

@@ -97,0 +97,0 @@ });

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var spawn = require("cross-spawn");
var cp = require("child_process");

@@ -8,3 +20,2 @@ var path = require("path");

var arguments_1 = require("./arguments");
var _ = require('underscore');
var Spawn = (function () {

@@ -25,3 +36,2 @@ function Spawn() {

delete envVars['RUBYGEMS_GEMDEPS'];
var file;
var opts = {

@@ -32,22 +42,5 @@ cwd: pact_environment_1.default.cwd,

};
var cmd = [command]
.concat(arguments_1.default.toArgumentsArray(args, argMapping))
.join(' ');
var spawnArgs;
if (pact_environment_1.default.isWindows()) {
file = 'cmd.exe';
spawnArgs = ['/s', '/c', cmd];
(opts).windowsVerbatimArguments = true;
}
else {
cmd = "./" + cmd;
file = '/bin/sh';
spawnArgs = ['-c', cmd];
}
logger_1.default.debug("Starting pact binary with '" + _.flatten([
file,
spawnArgs,
JSON.stringify(opts),
]) + "'");
var instance = cp.spawn(file, spawnArgs, opts);
var spawnArgs = arguments_1.default.toArgumentsArray(args, __assign({ cliVerb: arguments_1.DEFAULT_ARG }, argMapping));
logger_1.default.debug("Starting pact binary '" + command + "', with arguments [" + spawnArgs.join(' ') + "], and environment: " + JSON.stringify(opts));
var instance = spawn(command, spawnArgs, opts);
instance.stdout.setEncoding('utf8');

@@ -63,3 +56,3 @@ instance.stderr.setEncoding('utf8');

});
logger_1.default.debug("Created '" + cmd + "' process with PID: " + instance.pid);
logger_1.default.debug("Created '" + command + "' process with PID: " + instance.pid);
return instance;

@@ -70,3 +63,3 @@ };

var pid = binary.pid;
logger_1.default.info("Removing Pact with PID: " + pid);
logger_1.default.info("Removing Pact process with PID: " + pid);
binary.removeAllListeners();

@@ -73,0 +66,0 @@ try {

@@ -69,3 +69,4 @@ "use strict";

checkTypes.assert.nonEmptyString(options.providerBaseUrl);
if (checkTypes.emptyArray(options.pactUrls) && !options.pactBrokerUrl) {
if (checkTypes.emptyArray(options.pactUrls) &&
!options.pactBrokerUrl) {
throw new Error('Must provide the pactUrls argument if no pactBrokerUrl provided');

@@ -72,0 +73,0 @@ }

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