New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stryker

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stryker - npm Package Compare versions

Comparing version 0.5.7 to 0.5.8

src/mutators/ArrayDeclaratorMutator.d.ts

17

CHANGELOG.md

@@ -0,1 +1,18 @@

<a name="0.5.8"></a>
## [0.5.8](https://github.com/stryker-mutator/stryker/compare/v0.5.7...v0.5.8) (2017-02-03)
### Bug Fixes
* **bin/stryker:** Changed file permissions on stryker so it's executable on Linux ([#226](https://github.com/stryker-mutator/stryker/issues/226)) ([c1a5798](https://github.com/stryker-mutator/stryker/commit/c1a5798))
* **fs:** Use graceful-fs instead of fs directly ([#221](https://github.com/stryker-mutator/stryker/issues/221)) ([4c1bf41](https://github.com/stryker-mutator/stryker/commit/4c1bf41))
* **typo:** change not coverage to no coverage ([f2c7198](https://github.com/stryker-mutator/stryker/commit/f2c7198))
### Features
* **ArrayDeclarationMutator:** Add new mutator. ([#229](https://github.com/stryker-mutator/stryker/issues/229)) ([9805917](https://github.com/stryker-mutator/stryker/commit/9805917))
<a name="0.5.7"></a>

@@ -2,0 +19,0 @@ ## [0.5.7](https://github.com/stryker-mutator/stryker/compare/v0.5.6...v0.5.7) (2017-01-16)

36

package.json
{
"name": "stryker",
"version": "0.5.7",
"version": "0.5.8",
"description": "The extendable JavaScript mutation testing framework",

@@ -11,3 +11,12 @@ "main": "src/Stryker.js",

"sample": "node src/stryker-cli.js --configFile testResources/sampleProject/stryker.conf.js",
"preversion": "grunt"
"preversion": "grunt",
"clean": "grunt clean",
"jshint": "grunt jshint",
"tslint": "grunt tslint",
"coverage": "grunt coverage",
"intergration": "grunt intergration",
"build": "grunt build",
"serve": "grunt serve",
"watch-test": "grunt watch-test",
"release": "grunt release"
},

@@ -33,2 +42,3 @@ "repository": {

"Nico Jansen <jansennico@gmail.com>",
"Sander Koenders <sanderkoenders@gmail.com>",
"global <jansennico@gmail.com>",

@@ -39,2 +49,3 @@ "Philipp Weissenbacher <philipp.weissenbacher@gmail.com>",

"Alex van Assem <avassem@gmail.com>",
"Jelle Peters <JellePetersHAN@users.noreply.github.com>",
"Jeremy Nagel <jeremy.nagel@learnosity.com>",

@@ -50,20 +61,23 @@ "Michael Williamson <mike@zwobble.org>"

"commander": "^2.9.0",
"es6-promise-pool": "^2.4.1",
"es6-promise-pool": "^2.4.4",
"escodegen": "^1.8.0",
"esprima": "^2.7.0",
"glob": "^7.0.3",
"graceful-fs": "^4.1.11",
"istanbul": "^0.4.5",
"lodash": "^3.10.1",
"log4js": "^0.6.33",
"lodash": "^4.17.4",
"log4js": "^1.1.0",
"mkdirp": "^0.5.1",
"progress": "^1.1.8",
"serialize-javascript": "^1.3.0"
"serialize-javascript": "^1.3.0",
"tslib": "^1.5.0"
},
"devDependencies": {
"@types/chai-as-promised": "0.0.28",
"@types/chai-as-promised": "0.0.29",
"@types/chalk": "^0.4.28",
"@types/escodegen": "0.0.5",
"@types/escodegen": "0.0.6",
"@types/esprima": "^2.1.31",
"@types/estree": "0.0.32",
"@types/glob": "^5.0.29",
"@types/graceful-fs": "^2.0.29",
"@types/istanbul": "^0.4.29",

@@ -92,3 +106,3 @@ "@types/karma": "^0.13.32",

"grunt-ts": "^6.0.0-beta.3",
"grunt-tslint": "^3.2.1",
"grunt-tslint": "^4.0.0",
"jasmine-core": "^2.4.1",

@@ -100,3 +114,3 @@ "karma": "1.0.0",

"load-grunt-tasks": "^3.5.0",
"mocha": "^2.3.3",
"mocha": "^3.2.0",
"sinon": "^1.17.2",

@@ -106,3 +120,3 @@ "sinon-as-promised": "^4.0.2",

"stryker-api": "^0.4.2",
"tslint": "^3.15.1",
"tslint": "^4.4.2",
"typescript": "^2.1.4"

@@ -109,0 +123,0 @@ },

import { Config } from 'stryker-api/config';
import { StrykerOptions } from 'stryker-api/core';
export declare var CONFIG_SYNTAX_HELP: string;
export declare const CONFIG_SYNTAX_HELP: string;
export default class ConfigReader {

@@ -5,0 +5,0 @@ private cliOptions;

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

ConfigReader.prototype.loadConfigModule = function () {
var configModule;
// we start with a dummy configModule
var configModule = function () { };
if (this.cliOptions.configFile) {

@@ -61,4 +62,2 @@ log.debug('Loading config %s', this.cliOptions.configFile);

log.info('No config file specified. Running with command line arguments');
// if no config file path is passed, we define a dummy config module.
configModule = function () { };
}

@@ -65,0 +64,0 @@ return configModule;

@@ -17,3 +17,3 @@ /// <reference types="node" />

private coverageInstrumenterStreamPerFile;
constructor(coverageAnalysis: 'all' | 'off' | 'perTest', testFramework: TestFramework);
constructor(coverageAnalysis: 'all' | 'off' | 'perTest', testFramework: TestFramework | null);
instrumenterStreamForFile(file: InputFile): NodeJS.ReadWriteStream;

@@ -20,0 +20,0 @@ hooksForTestRun(): string;

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

CoverageInstrumenter.prototype.hooksForTestRun = function () {
if (this.coverageAnalysis === 'perTest') {
if (this.testFramework && this.coverageAnalysis === 'perTest') {
log.debug("Adding test hooks file for coverageAnalysis \"perTest\"");
return objectUtils_1.wrapInClosure("\n var id = 0, coverageStateAtStart;\n window.__coverage__ = globalCoverage = {};\n\n " + this.testFramework.beforeEach(beforeEachFragmentPerTest) + "\n " + this.testFramework.afterEach(afterEachFragmentPerTest) + "\n " + cloneFunctionFragment + ";\n ");
return objectUtils_1.wrapInClosure("\n var id = 0, coverageStateAtStart;\n window.__coverage__ = globalCoverage = {};\n " + this.testFramework.beforeEach(beforeEachFragmentPerTest) + "\n " + this.testFramework.afterEach(afterEachFragmentPerTest) + "\n " + cloneFunctionFragment + ";\n ");
}

@@ -46,0 +46,0 @@ else {

@@ -11,3 +11,2 @@ /// <reference types="node" />

private filename;
private opts;
private source;

@@ -14,0 +13,0 @@ statementMap: StatementMap;

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var tslib_1 = require("tslib");
var stream_1 = require("stream");

@@ -17,3 +13,3 @@ var istanbul_1 = require("istanbul");

var CoverageInstrumenterStream = (function (_super) {
__extends(CoverageInstrumenterStream, _super);
tslib_1.__extends(CoverageInstrumenterStream, _super);
function CoverageInstrumenterStream(coverageVariable, filename, opts) {

@@ -23,3 +19,2 @@ var _this = _super.call(this, opts) || this;

_this.filename = filename;
_this.opts = opts;
_this.source = '';

@@ -42,3 +37,3 @@ return _this;

coverageObjRegex.lastIndex = 0;
var coverageObjectMatch = coverageObjRegex.exec(instrumentedCode).toString();
var coverageObjectMatch = coverageObjRegex.exec(instrumentedCode) + '';
var coverageObj = JSON.parse(coverageObjectMatch);

@@ -45,0 +40,0 @@ this.statementMap = coverageObj.statementMap;

"use strict";
var tslib_1 = require("tslib");
var fileUtils_1 = require("./utils/fileUtils");

@@ -15,9 +16,16 @@ var _ = require("lodash");

InputFileResolver.prototype.resolve = function () {
var _this = this;
return Promise.all([this.inputFileResolver.resolve(), this.mutateResolver.resolve()]).then(function (results) {
var inputFiles = results[0];
var mutateFiles = results[1];
_this.markAdditionalFilesToMutate(inputFiles, mutateFiles.map(function (m) { return m.path; }));
_this.logFilesToMutate(inputFiles);
return inputFiles;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var results, inputFiles, mutateFiles;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all([this.inputFileResolver.resolve(), this.mutateResolver.resolve()])];
case 1:
results = _a.sent();
inputFiles = results[0];
mutateFiles = results[1];
this.markAdditionalFilesToMutate(inputFiles, mutateFiles.map(function (m) { return m.path; }));
this.logFilesToMutate(inputFiles);
return [2 /*return*/, inputFiles];
}
});
});

@@ -93,30 +101,33 @@ };

PatternResolver.prototype.resolve = function () {
var _this = this;
// When the first expression starts with an '!', we skip that one
if (this.ignore && !this.previous) {
return Promise.resolve([]);
}
else {
// Start the globbing task for the current descriptor
var globbingTask = this.resolveGlobbingExpression(this.descriptor.pattern)
.then(function (filePaths) { return filePaths.map(function (filePath) { return _this.createInputFile(filePath); }); });
// If there is a previous globbing expression, resolve that one as well
if (this.previous) {
return Promise.all([this.previous.resolve(), globbingTask]).then(function (results) {
var previousFiles = results[0];
var currentFiles = results[1];
// If this expression started with a '!', exclude current files
if (_this.ignore) {
return previousFiles.filter(function (previousFile) { return currentFiles.every(function (currentFile) { return previousFile.path !== currentFile.path; }); });
}
else {
// Only add files which were not already added
return previousFiles.concat(currentFiles.filter(function (currentFile) { return !previousFiles.some(function (file) { return file.path === currentFile.path; }); }));
}
});
}
else {
return globbingTask;
}
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
var globbingTask, results, previousFiles_1, currentFiles_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(this.ignore && !this.previous)) return [3 /*break*/, 1];
return [2 /*return*/, Promise.resolve([])];
case 1:
globbingTask = this.resolveGlobbingExpression(this.descriptor.pattern)
.then(function (filePaths) { return filePaths.map(function (filePath) { return _this.createInputFile(filePath); }); });
if (!this.previous) return [3 /*break*/, 3];
return [4 /*yield*/, Promise.all([this.previous.resolve(), globbingTask])];
case 2:
results = _a.sent();
previousFiles_1 = results[0];
currentFiles_1 = results[1];
// If this expression started with a '!', exclude current files
if (this.ignore) {
return [2 /*return*/, previousFiles_1.filter(function (previousFile) { return currentFiles_1.every(function (currentFile) { return previousFile.path !== currentFile.path; }); })];
}
else {
// Only add files which were not already added
return [2 /*return*/, previousFiles_1.concat(currentFiles_1.filter(function (currentFile) { return !previousFiles_1.some(function (file) { return file.path === currentFile.path; }); }))];
}
return [3 /*break*/, 4];
case 3: return [2 /*return*/, globbingTask];
case 4: return [2 /*return*/];
}
});
});
};

@@ -131,4 +142,6 @@ PatternResolver.empty = function () {

var current = PatternResolver.empty();
while (expressions.length) {
current = new PatternResolver(expressions.shift(), current);
var expression = expressions.shift();
while (expression) {
current = new PatternResolver(expression, current);
expression = expressions.shift();
}

@@ -138,15 +151,20 @@ return current;

PatternResolver.prototype.resolveGlobbingExpression = function (pattern) {
var _this = this;
if (fileUtils_1.isOnlineFile(pattern)) {
return Promise.resolve([pattern]);
}
else {
return fileUtils_1.glob(pattern).then(function (files) {
if (files.length === 0) {
_this.reportEmptyGlobbingExpression(pattern);
return tslib_1.__awaiter(this, void 0, void 0, function () {
var files;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!fileUtils_1.isOnlineFile(pattern)) return [3 /*break*/, 1];
return [2 /*return*/, Promise.resolve([pattern])];
case 1: return [4 /*yield*/, fileUtils_1.glob(pattern)];
case 2:
files = _a.sent();
if (files.length === 0) {
this.reportEmptyGlobbingExpression(pattern);
}
fileUtils_1.normalize(files);
return [2 /*return*/, files];
}
fileUtils_1.normalize(files);
return files;
});
}
});
};

@@ -153,0 +171,0 @@ PatternResolver.prototype.reportEmptyGlobbingExpression = function (expression) {

@@ -30,3 +30,3 @@ /// <reference types="node" />

private sendRunCommand(options);
private send<T>(message);
private send(message);
private sendStartCommand();

@@ -33,0 +33,0 @@ private sendInitCommand();

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var tslib_1 = require("tslib");
var events_1 = require("events");

@@ -20,3 +16,3 @@ var log4js = require("log4js");

var TestRunnerChildProcessAdapter = (function (_super) {
__extends(TestRunnerChildProcessAdapter, _super);
tslib_1.__extends(TestRunnerChildProcessAdapter, _super);
function TestRunnerChildProcessAdapter(realTestRunnerName, options) {

@@ -23,0 +19,0 @@ var _this = _super.call(this) || this;

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

create: function (settings) {
return new IsolatedTestRunnerAdapter_1.default(settings.strykerOptions.testRunner, settings);
return new IsolatedTestRunnerAdapter_1.default(settings.strykerOptions.testRunner || '', settings);
}
};
//# sourceMappingURL=IsolatedTestRunnerAdapterFactory.js.map
"use strict";
var tslib_1 = require("tslib");
var test_runner_1 = require("stryker-api/test_runner");

@@ -37,3 +38,3 @@ var PluginLoader_1 = require("../PluginLoader");

IsolatedTestRunnerAdapterWorker.prototype.start = function (message) {
this.loadPlugins(message.runnerOptions.strykerOptions.plugins);
this.loadPlugins(message.runnerOptions.strykerOptions.plugins || []);
log.debug("Changing current working directory for this process to " + message.runnerOptions.sandboxWorkingFolder);

@@ -44,28 +45,41 @@ process.chdir(message.runnerOptions.sandboxWorkingFolder);

IsolatedTestRunnerAdapterWorker.prototype.init = function () {
var initPromise = void 0;
if (this.underlyingTestRunner.init) {
initPromise = this.underlyingTestRunner.init();
}
if (objectUtils_1.isPromise(initPromise)) {
initPromise.then(this.sendInitDone);
}
else {
this.sendInitDone();
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.underlyingTestRunner.init) return [3 /*break*/, 2];
return [4 /*yield*/, this.underlyingTestRunner.init()];
case 1:
_a.sent();
_a.label = 2;
case 2:
;
this.sendInitDone();
return [2 /*return*/];
}
});
});
};
IsolatedTestRunnerAdapterWorker.prototype.sendInitDone = function () {
var message = { kind: 'initDone' };
process.send(message);
if (process.send) {
process.send(message);
}
};
IsolatedTestRunnerAdapterWorker.prototype.dispose = function () {
var disposePromise = void 0;
if (this.underlyingTestRunner.dispose) {
disposePromise = this.underlyingTestRunner.dispose();
}
if (objectUtils_1.isPromise(disposePromise)) {
disposePromise.then(this.sendDisposeDone);
}
else {
this.sendDisposeDone();
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.underlyingTestRunner.dispose) return [3 /*break*/, 2];
return [4 /*yield*/, this.underlyingTestRunner.dispose()];
case 1:
_a.sent();
_a.label = 2;
case 2:
this.sendDisposeDone();
return [2 /*return*/];
}
});
});
};

@@ -76,7 +90,26 @@ IsolatedTestRunnerAdapterWorker.prototype.sendDisposeDone = function () {

IsolatedTestRunnerAdapterWorker.prototype.run = function (body) {
var _this = this;
this.underlyingTestRunner.run(body.runOptions).then(function (res) { return _this.reportResult(res); }, function (error) { return _this.reportErrorResult(error); });
return tslib_1.__awaiter(this, void 0, void 0, function () {
var res, error_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.underlyingTestRunner.run(body.runOptions)];
case 1:
res = _a.sent();
this.reportResult(res);
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
this.reportErrorResult(error_1);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
}
});
});
};
IsolatedTestRunnerAdapterWorker.prototype.send = function (message) {
process.send(message);
if (process.send) {
process.send(message);
}
};

@@ -96,3 +129,3 @@ IsolatedTestRunnerAdapterWorker.prototype.loadPlugins = function (plugins) {

result.errorMessages = result.errorMessages.map(function (error) {
if (error instanceof Error) {
if (error instanceof Error && error.stack) {
return error.name + ": " + error.message + "\n" + error.stack.toString();

@@ -99,0 +132,0 @@ }

import Mutant from './Mutant';
import { Reporter } from 'stryker-api/report';
import StrictReporter from './reporters/StrictReporter';
import { StatementMapDictionary } from './coverage/CoverageInstrumenter';

@@ -12,3 +12,3 @@ import { RunResult } from 'stryker-api/test_runner';

private reporter;
constructor(mutants: Mutant[], initialRunResult: RunResult, statementMaps: StatementMapDictionary, options: StrykerOptions, reporter: Reporter);
constructor(mutants: Mutant[], initialRunResult: RunResult, statementMaps: StatementMapDictionary, options: StrykerOptions, reporter: StrictReporter);
matchWithMutants(): void;

@@ -15,0 +15,0 @@ /**

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

var location = statementMap[statementId];
if (_this.statementCoversMutant(mutant.location, location) && _this.isNewSmallestStatement(statementMap[smallestStatement], location)) {
if (_this.statementCoversMutant(mutant.location, location) && (!smallestStatement || _this.isNewSmallestStatement(statementMap[smallestStatement], location))) {
smallestStatement = statementId;

@@ -66,0 +66,0 @@ }

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

import { Reporter } from 'stryker-api/report';
import Mutant from './Mutant';
import StrictReporter from './reporters/StrictReporter';
/**

@@ -13,3 +13,3 @@ * Class capable of finding spots to mutate in files.

*/
constructor(reporter: Reporter);
constructor(reporter: StrictReporter);
/**

@@ -16,0 +16,0 @@ * Mutates source files. Mutated code is not writen to disk.

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

var UpdateOperatorMutator_1 = require("./mutators/UpdateOperatorMutator");
var ArrayDeclaratorMutator_1 = require("./mutators/ArrayDeclaratorMutator");
var mutant_1 = require("stryker-api/mutant");

@@ -29,3 +30,3 @@ var fileUtils = require("./utils/fileUtils");

var mutatorFactory = mutant_1.MutatorFactory.instance();
mutatorFactory.knownNames().forEach(function (name) { return _this.mutators.push(mutatorFactory.create(name, null)); });
mutatorFactory.knownNames().forEach(function (name) { return _this.mutators.push(mutatorFactory.create(name, undefined)); });
}

@@ -84,2 +85,3 @@ /**

mutatorFactory.register('UpdateOperator', UpdateOperatorMutator_1.default);
mutatorFactory.register('ArrayDeclarator', ArrayDeclaratorMutator_1.default);
};

@@ -86,0 +88,0 @@ /**

@@ -5,4 +5,5 @@ import { Mutator } from 'stryker-api/mutant';

name: string;
private type;
private operators;
applyMutations(node: estree.Node, copy: <T>(obj: T, deep?: boolean) => T): estree.Node[];
}

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

this.name = 'BinaryOperator';
this.type = esprima_1.Syntax.BinaryExpression;
this.operators = {

@@ -25,3 +26,3 @@ '+': '-',

var nodes = [];
if (node.type === esprima_1.Syntax.BinaryExpression && this.operators[node.operator]) {
if (node.type === this.type && this.operators[node.operator]) {
var binaryNode_1 = node;

@@ -28,0 +29,0 @@ var mutatedOperators = this.operators[node.operator];

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

BlockStatementMutator.prototype.applyMutations = function (node, copy) {
if (node.type === esprima_1.Syntax.BlockStatement && node.body.length > 0) {
if (node.type === this.type && node.body.length > 0) {
var mutatedNode = copy(node);

@@ -15,0 +15,0 @@ mutatedNode.body = [];

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

var nodes = [];
if (node.type === esprima_1.Syntax.LogicalExpression && this.operators[node.operator]) {
if (node.type === this.type && this.operators[node.operator]) {
var mutatedNode = copy(node);

@@ -17,0 +17,0 @@ mutatedNode.operator = this.operators[node.operator];

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

var mutatedNode = copy(node);
mutatedNode.test = this.booleanLiteralNode(null, false);
mutatedNode.test = this.booleanLiteralNode(-1, false);
nodes.push(mutatedNode);

@@ -22,0 +22,0 @@ }

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

var nodes = [];
if (node.type === esprima_1.Syntax.UnaryExpression && this.operators[node.operator]) {
if (node.type === this.type && this.operators[node.operator]) {
var mutatedNode = copy(node);

@@ -17,0 +17,0 @@ mutatedNode.operator = this.operators[node.operator];

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

var nodes = [];
if (node.type === esprima_1.Syntax.UpdateExpression && this.operators[node.operator]) {
if (node.type === this.type && this.operators[node.operator]) {
var mutatedNode = copy(node);

@@ -17,0 +17,0 @@ mutatedNode.operator = this.operators[node.operator];

"use strict";
var fs = require("fs");
var fs = require("graceful-fs");
var path = require("path");

@@ -4,0 +4,0 @@ var log4js = require("log4js");

import { StrykerOptions } from 'stryker-api/core';
import { Reporter } from 'stryker-api/report';
import StrictReporter from './reporters/StrictReporter';
export default class ReporterOrchestrator {
private options;
constructor(options: StrykerOptions);
createBroadcastReporter(): Reporter;
createBroadcastReporter(): StrictReporter;
private createReporter(name);
private logPossibleReporters();
}

@@ -1,2 +0,3 @@

import { Reporter } from 'stryker-api/report';
import { Reporter, SourceFile, MutantResult, MatchedMutant } from 'stryker-api/report';
import StrictReporter from './StrictReporter';
export interface NamedReporter {

@@ -6,8 +7,13 @@ name: string;

}
export declare const ALL_EVENT_METHOD_NAMES: string[];
export default class BroadcastReporter implements Reporter {
export default class BroadcastReporter implements StrictReporter {
private reporters;
constructor(reporters: NamedReporter[]);
private broadcast(methodName, eventArgs);
private broadcast(methodName, eventArgs?);
onSourceFileRead(file: SourceFile): void;
onAllSourceFilesRead(files: SourceFile[]): void;
onAllMutantsMatchedWithTests(results: ReadonlyArray<MatchedMutant>): void;
onMutantTested(result: MutantResult): void;
onAllMutantsTested(results: MutantResult[]): void;
wrapUp(): void | Promise<void>;
private handleError(error, methodName, reporterName);
}

@@ -5,21 +5,14 @@ "use strict";

var log = log4js.getLogger('BroadcastReporter');
exports.ALL_EVENT_METHOD_NAMES = ['onSourceFileRead', 'onAllSourceFilesRead', 'onAllMutantsMatchedWithTests', 'onMutantTested', 'onAllMutantsTested', 'onConfigRead'];
var BroadcastReporter = (function () {
function BroadcastReporter(reporters) {
var _this = this;
this.reporters = reporters;
exports.ALL_EVENT_METHOD_NAMES.concat('wrapUp').forEach(function (method) {
_this[method] = function (arg) {
return _this.broadcast(method, arg);
};
});
}
BroadcastReporter.prototype.broadcast = function (methodName, eventArgs) {
var _this = this;
if (eventArgs === void 0) { eventArgs = undefined; }
var allPromises = [];
this.reporters.forEach(function (namedReporter) {
var reporter = namedReporter.reporter;
if (reporter[methodName] && typeof reporter[methodName] === 'function') {
if (typeof namedReporter.reporter[methodName] === 'function') {
try {
var maybePromise = reporter[methodName](eventArgs);
var maybePromise = namedReporter.reporter[methodName](eventArgs);
if (objectUtils_1.isPromise(maybePromise)) {

@@ -40,2 +33,20 @@ allPromises.push(maybePromise.catch(function (error) {

};
BroadcastReporter.prototype.onSourceFileRead = function (file) {
this.broadcast('onSourceFileRead', file);
};
BroadcastReporter.prototype.onAllSourceFilesRead = function (files) {
this.broadcast('onAllSourceFilesRead', files);
};
BroadcastReporter.prototype.onAllMutantsMatchedWithTests = function (results) {
this.broadcast('onAllMutantsMatchedWithTests', results);
};
BroadcastReporter.prototype.onMutantTested = function (result) {
this.broadcast('onMutantTested', result);
};
BroadcastReporter.prototype.onAllMutantsTested = function (results) {
this.broadcast('onAllMutantsTested', results);
};
BroadcastReporter.prototype.wrapUp = function () {
return this.broadcast('wrapUp');
};
BroadcastReporter.prototype.handleError = function (error, methodName, reporterName) {

@@ -42,0 +53,0 @@ log.error("An error occurred during '" + methodName + "' on reporter '" + reporterName + "'. Error is: " + error);

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

mutantsNoCoverage++;
_this.writeLine(chalk.bold.yellow('Mutant survived! (not coverage)'));
_this.writeLine(chalk.bold.yellow('Mutant survived! (no coverage)'));
_this.logMutantResult(result, writeLineFn);

@@ -56,0 +56,0 @@ break;

@@ -1,4 +0,5 @@

import { Reporter } from 'stryker-api/report';
import { StrykerOptions } from 'stryker-api/core';
export default class EventRecorderReporter implements Reporter {
import { SourceFile, MutantResult, MatchedMutant } from 'stryker-api/report';
import StrictReporter from './StrictReporter';
export default class EventRecorderReporter implements StrictReporter {
private options;

@@ -8,2 +9,3 @@ private allWork;

private _baseFolder;
private index;
constructor(options: StrykerOptions);

@@ -13,3 +15,8 @@ private readonly baseFolder;

private format(input);
onSourceFileRead(file: SourceFile): void;
onAllSourceFilesRead(files: SourceFile[]): void;
onAllMutantsMatchedWithTests(results: ReadonlyArray<MatchedMutant>): void;
onMutantTested(result: MutantResult): void;
onAllMutantsTested(results: MutantResult[]): void;
wrapUp(): Promise<any>;
}
"use strict";
var BroadcastReporter_1 = require("./BroadcastReporter");
var fileUtils = require("../utils/fileUtils");
var tslib_1 = require("tslib");
var log4js = require("log4js");
var path = require("path");
var fileUtils = require("../utils/fileUtils");
var log = log4js.getLogger('EventRecorderReporter');

@@ -10,12 +10,6 @@ var DEFAULT_BASE_FOLDER = 'reports/mutation/events';

function EventRecorderReporter(options) {
var _this = this;
this.options = options;
this.allWork = [];
var index = 0;
this.index = 0;
this.createBaseFolderTask = fileUtils.cleanFolder(this.baseFolder);
BroadcastReporter_1.ALL_EVENT_METHOD_NAMES.forEach(function (method) {
_this[method] = function (data) {
_this.allWork.push(_this.createBaseFolderTask.then(function () { return _this.writeToFile(index++, method, data); }));
};
});
}

@@ -53,6 +47,35 @@ Object.defineProperty(EventRecorderReporter.prototype, "baseFolder", {

};
EventRecorderReporter.prototype.wrapUp = function () {
EventRecorderReporter.prototype.onSourceFileRead = function (file) {
var _this = this;
return this.createBaseFolderTask.then(function () { return Promise.all(_this.allWork); });
this.allWork.push(this.createBaseFolderTask
.then(function () { return _this.writeToFile(_this.index++, 'onSourceFileRead', file); }));
};
EventRecorderReporter.prototype.onAllSourceFilesRead = function (files) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllSourceFilesRead', files); }));
};
EventRecorderReporter.prototype.onAllMutantsMatchedWithTests = function (results) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllMutantsMatchedWithTests', results); }));
};
EventRecorderReporter.prototype.onMutantTested = function (result) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onMutantTested', result); }));
};
EventRecorderReporter.prototype.onAllMutantsTested = function (results) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllMutantsTested', results); }));
};
EventRecorderReporter.prototype.wrapUp = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.createBaseFolderTask];
case 1:
_a.sent();
return [2 /*return*/, Promise.all(this.allWork)];
}
});
});
};
return EventRecorderReporter;

@@ -59,0 +82,0 @@ }());

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var tslib_1 = require("tslib");
var os = require("os");

@@ -11,5 +7,5 @@ var ProgressKeeper_1 = require("./ProgressKeeper");

var ProgressAppendOnlyReporter = (function (_super) {
__extends(ProgressAppendOnlyReporter, _super);
tslib_1.__extends(ProgressAppendOnlyReporter, _super);
function ProgressAppendOnlyReporter() {
return _super.apply(this, arguments) || this;
return _super !== null && _super.apply(this, arguments) || this;
}

@@ -16,0 +12,0 @@ ProgressAppendOnlyReporter.prototype.onAllMutantsMatchedWithTests = function (matchedMutants) {

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var tslib_1 = require("tslib");
var ProgressKeeper_1 = require("./ProgressKeeper");
var ProgressBar_1 = require("./ProgressBar");
var ProgressBarReporter = (function (_super) {
__extends(ProgressBarReporter, _super);
tslib_1.__extends(ProgressBarReporter, _super);
function ProgressBarReporter() {
return _super.apply(this, arguments) || this;
return _super !== null && _super.apply(this, arguments) || this;
}

@@ -14,0 +10,0 @@ ProgressBarReporter.prototype.onAllMutantsMatchedWithTests = function (matchedMutants) {

@@ -16,3 +16,3 @@ import { RunResult } from 'stryker-api/test_runner';

private testHooksFile;
constructor(options: StrykerOptions, index: number, files: InputFile[], testFramework: TestFramework, coverageInstrumenter: CoverageInstrumenter);
constructor(options: StrykerOptions, index: number, files: InputFile[], testFramework: TestFramework | null, coverageInstrumenter: CoverageInstrumenter | null);
initialize(): Promise<void>;

@@ -19,0 +19,0 @@ run(timeout: number): Promise<RunResult>;

"use strict";
var tslib_1 = require("tslib");
var path = require("path");

@@ -22,5 +23,12 @@ var log4js = require("log4js");

Sandbox.prototype.initialize = function () {
var _this = this;
return this.fillSandbox()
.then(function () { return _this.initializeTestRunner(); });
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.fillSandbox()];
case 1:
_a.sent();
return [2 /*return*/, this.initializeTestRunner()];
}
});
});
};

@@ -34,7 +42,21 @@ Sandbox.prototype.run = function (timeout) {

Sandbox.prototype.runMutant = function (mutant) {
var _this = this;
var targetedFile = this.fileMap[mutant.filename];
return Promise.all([mutant.save(targetedFile), this.filterTests(mutant)])
.then(function () { return _this.run(_this.calculateTimeout(mutant)); })
.then(function (runResult) { return mutant.reset(targetedFile).then(function () { return runResult; }); });
return tslib_1.__awaiter(this, void 0, void 0, function () {
var targetedFile, runResult;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
targetedFile = this.fileMap[mutant.filename];
return [4 /*yield*/, Promise.all([mutant.save(targetedFile), this.filterTests(mutant)])];
case 1:
_a.sent();
return [4 /*yield*/, this.run(this.calculateTimeout(mutant))];
case 2:
runResult = _a.sent();
return [4 /*yield*/, mutant.reset(targetedFile)];
case 3:
_a.sent();
return [2 /*return*/, runResult];
}
});
});
};

@@ -41,0 +63,0 @@ Sandbox.prototype.fillSandbox = function () {

@@ -1,7 +0,9 @@

import { StrykerOptions, InputFile } from 'stryker-api/core';
import { InputFile } from 'stryker-api/core';
import { Config } from 'stryker-api/config';
import { RunResult } from 'stryker-api/test_runner';
import { Reporter, MutantResult } from 'stryker-api/report';
import { MutantResult } from 'stryker-api/report';
import { TestFramework } from 'stryker-api/test_framework';
import CoverageInstrumenter from './coverage/CoverageInstrumenter';
import Mutant from './Mutant';
import StrictReporter from './reporters/StrictReporter';
export default class SandboxCoordinator {

@@ -12,3 +14,3 @@ private options;

private reporter;
constructor(options: StrykerOptions, files: InputFile[], testFramework: TestFramework, reporter: Reporter);
constructor(options: Config, files: InputFile[], testFramework: TestFramework | null, reporter: StrictReporter);
initialRun(coverageInstrumenter: CoverageInstrumenter): Promise<RunResult>;

@@ -18,4 +20,4 @@ runMutants(mutants: Mutant[]): Promise<MutantResult[]>;

private reportMutantTested(mutant, runResult, results);
private collectFrozenMutantResult(mutant, runResult?);
private collectFrozenMutantResult(mutant, runResult);
private reportAllMutantsTested(results);
}
"use strict";
var tslib_1 = require("tslib");
var log4js = require("log4js");

@@ -23,53 +24,98 @@ var os = require("os");

SandboxCoordinator.prototype.initialRun = function (coverageInstrumenter) {
log.info("Starting initial test run. This may take a while.");
var sandbox = new Sandbox_1.default(this.options, 0, this.files, this.testFramework, coverageInstrumenter);
return sandbox
.initialize()
.then(function () { return sandbox.run(INITIAL_RUN_TIMEOUT); })
.then(function (runResult) { return sandbox.dispose().then(function () { return runResult; }); });
return tslib_1.__awaiter(this, void 0, void 0, function () {
var sandbox, runResult;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
log.info("Starting initial test run. This may take a while.");
sandbox = new Sandbox_1.default(this.options, 0, this.files, this.testFramework, coverageInstrumenter);
return [4 /*yield*/, sandbox.initialize()];
case 1:
_a.sent();
return [4 /*yield*/, sandbox.run(INITIAL_RUN_TIMEOUT)];
case 2:
runResult = _a.sent();
return [4 /*yield*/, sandbox.dispose()];
case 3:
_a.sent();
return [2 /*return*/, runResult];
}
});
});
};
SandboxCoordinator.prototype.runMutants = function (mutants) {
var _this = this;
mutants = _.clone(mutants); // work with a copy because we're changing state (pop'ing values)
var results = [];
return this.createSandboxes().then(function (sandboxes) {
var promiseProducer = function () {
if (mutants.length === 0) {
return null; // we're done
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
var results, sandboxes, promiseProducer;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
mutants = _.clone(mutants); // work with a copy because we're changing state (pop'ing values)
results = [];
return [4 /*yield*/, this.createSandboxes()];
case 1:
sandboxes = _a.sent();
promiseProducer = function () {
var mutant = mutants.shift();
if (!mutant) {
return null; // we're done
}
else {
if (mutant.scopedTestIds.length > 0) {
var sandbox_1 = sandboxes.shift();
if (sandbox_1) {
return sandbox_1.runMutant(mutant)
.then(function (runResult) {
_this.reportMutantTested(mutant, runResult, results);
sandboxes.push(sandbox_1); // mark the sandbox as available again
});
}
else {
return null;
}
}
else {
_this.reportMutantTested(mutant, null, results);
return Promise.resolve();
}
}
};
return [4 /*yield*/, new PromisePool(promiseProducer, sandboxes.length).start()];
case 2:
_a.sent();
return [4 /*yield*/, this.reportAllMutantsTested(results)];
case 3:
_a.sent();
return [4 /*yield*/, Promise.all(sandboxes.map(function (sandbox) { return sandbox.dispose(); }))];
case 4:
_a.sent();
return [2 /*return*/, results];
}
else {
var mutant_1 = mutants.shift();
if (mutant_1.scopedTestIds.length > 0) {
var sandbox_1 = sandboxes.shift();
return sandbox_1.runMutant(mutant_1)
.then(function (runResult) { return _this.reportMutantTested(mutant_1, runResult, results); })
.then(function () { return sandboxes.push(sandbox_1); }); // mark the sandbox as available again
}
else {
_this.reportMutantTested(mutant_1, null, results);
return Promise.resolve();
}
}
};
return new PromisePool(promiseProducer, sandboxes.length)
.start()
.then(function () { return _this.reportAllMutantsTested(results); })
.then(function () { return Promise.all(sandboxes.map(function (sandbox) { return sandbox.dispose(); })); })
.then(function () { return results; });
});
});
};
SandboxCoordinator.prototype.createSandboxes = function () {
var numConcurrentRunners = os.cpus().length;
var numConcurrentRunnersSource = 'CPU count';
if (numConcurrentRunners > this.options.maxConcurrentTestRunners && this.options.maxConcurrentTestRunners > 0) {
numConcurrentRunners = this.options.maxConcurrentTestRunners;
numConcurrentRunnersSource = 'maxConcurrentTestRunners config';
}
var sandboxes = [];
for (var i = 0; i < numConcurrentRunners; i++) {
sandboxes.push(new Sandbox_1.default(this.options, i, this.files, this.testFramework, null));
}
log.info("Creating " + numConcurrentRunners + " test runners (based on " + numConcurrentRunnersSource + ")");
return Promise.all(sandboxes.map(function (s) { return s.initialize(); }))
.then(function () { return sandboxes; });
return tslib_1.__awaiter(this, void 0, void 0, function () {
var numConcurrentRunners, numConcurrentRunnersSource, sandboxes, i;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
numConcurrentRunners = os.cpus().length;
numConcurrentRunnersSource = 'CPU count';
if (numConcurrentRunners > this.options.maxConcurrentTestRunners && this.options.maxConcurrentTestRunners > 0) {
numConcurrentRunners = this.options.maxConcurrentTestRunners;
numConcurrentRunnersSource = 'maxConcurrentTestRunners config';
}
sandboxes = [];
for (i = 0; i < numConcurrentRunners; i++) {
sandboxes.push(new Sandbox_1.default(this.options, i, this.files, this.testFramework, null));
}
log.info("Creating " + numConcurrentRunners + " test runners (based on " + numConcurrentRunnersSource + ")");
return [4 /*yield*/, Promise.all(sandboxes.map(function (s) { return s.initialize(); }))];
case 1:
_a.sent();
return [2 /*return*/, sandboxes];
}
});
});
};

@@ -82,3 +128,3 @@ SandboxCoordinator.prototype.reportMutantTested = function (mutant, runResult, results) {

SandboxCoordinator.prototype.collectFrozenMutantResult = function (mutant, runResult) {
var status;
var status = report_1.MutantStatus.NoCoverage;
var testNames;

@@ -108,3 +154,2 @@ if (runResult) {

testNames = [];
status = report_1.MutantStatus.NoCoverage;
}

@@ -111,0 +156,0 @@ var result = {

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

var log = log4js.getLogger('stryker-cli');
var command, strykerConfig;
var command = '', strykerConfig = null;
function list(val) {

@@ -10,0 +10,0 @@ return val.split(',');

'use strict';
var tslib_1 = require("tslib");
var MutatorOrchestrator_1 = require("./MutatorOrchestrator");

@@ -55,14 +56,32 @@ var config_1 = require("stryker-api/config");

Stryker.prototype.runMutationTest = function () {
var _this = this;
this.timer.reset();
return new InputFileResolver_1.default(this.config.mutate, this.config.files).resolve()
.then(function (inputFiles) { return _this.initialTestRun(inputFiles); })
.then(function (_a) {
var runResult = _a.runResult, inputFiles = _a.inputFiles, sandboxCoordinator = _a.sandboxCoordinator;
return _this.generateAndRunMutations(inputFiles, runResult, sandboxCoordinator);
})
.then(function (mutantResults) { return _this.wrapUpReporter()
.then(StrykerTempFolder_1.default.clean)
.then(function () { return _this.logDone(); })
.then(function () { return mutantResults; }); });
return tslib_1.__awaiter(this, void 0, void 0, function () {
var inputFiles, _a, runResult, sandboxCoordinator, mutantResults;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
this.timer.reset();
return [4 /*yield*/, new InputFileResolver_1.default(this.config.mutate, this.config.files).resolve()];
case 1:
inputFiles = _b.sent();
return [4 /*yield*/, this.initialTestRun(inputFiles)];
case 2:
_a = _b.sent(), runResult = _a.runResult, sandboxCoordinator = _a.sandboxCoordinator;
if (!(runResult && inputFiles && sandboxCoordinator)) return [3 /*break*/, 7];
return [4 /*yield*/, this.generateAndRunMutations(inputFiles, runResult, sandboxCoordinator)];
case 3:
mutantResults = _b.sent();
return [4 /*yield*/, this.wrapUpReporter()];
case 4:
_b.sent();
return [4 /*yield*/, StrykerTempFolder_1.default.clean()];
case 5:
_b.sent();
return [4 /*yield*/, this.logDone()];
case 6:
_b.sent();
return [2 /*return*/, mutantResults];
case 7: throw new Error('Resulting object did not contain runResult, inputFiles or sandboxCoordinator');
}
});
});
};

@@ -84,24 +103,33 @@ Stryker.prototype.filterOutFailedTests = function (runResult) {

Stryker.prototype.initialTestRun = function (inputFiles) {
var _this = this;
var sandboxCoordinator = new SandboxCoordinator_1.default(this.config, inputFiles, this.testFramework, this.reporter);
return sandboxCoordinator.initialRun(this.coverageInstrumenter)
.then(function (runResult) {
switch (runResult.status) {
case test_runner_1.RunStatus.Complete:
var failedTests = _this.filterOutFailedTests(runResult);
if (failedTests.length) {
_this.logFailedTestsInInitialRun(failedTests);
throw new Error('There were failed tests in the initial test run:');
}
else {
_this.logInitialTestRunSucceeded(runResult.tests);
return { runResult: runResult, inputFiles: inputFiles, sandboxCoordinator: sandboxCoordinator };
}
case test_runner_1.RunStatus.Error:
_this.logErrorredInitialRun(runResult);
break;
case test_runner_1.RunStatus.Timeout:
_this.logTimeoutInitialRun(runResult);
break;
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var sandboxCoordinator, runResult, failedTests;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
sandboxCoordinator = new SandboxCoordinator_1.default(this.config, inputFiles, this.testFramework, this.reporter);
return [4 /*yield*/, sandboxCoordinator.initialRun(this.coverageInstrumenter)];
case 1:
runResult = _a.sent();
switch (runResult.status) {
case test_runner_1.RunStatus.Complete:
failedTests = this.filterOutFailedTests(runResult);
if (failedTests.length) {
this.logFailedTestsInInitialRun(failedTests);
throw new Error('There were failed tests in the initial test run:');
}
else {
this.logInitialTestRunSucceeded(runResult.tests);
return [2 /*return*/, { runResult: runResult, sandboxCoordinator: sandboxCoordinator }];
}
case test_runner_1.RunStatus.Error:
this.logErrorredInitialRun(runResult);
break;
case test_runner_1.RunStatus.Timeout:
this.logTimeoutInitialRun(runResult);
break;
}
;
throw new Error('Something went wrong in the initial test run');
}
});
});

@@ -108,0 +136,0 @@ };

@@ -1,5 +0,6 @@

'use strict';
"use strict";
var tslib_1 = require("tslib");
var path = require("path");
var fs = require("graceful-fs");
var _ = require("lodash");
var fs = require("fs");
var path = require("path");
var nodeGlob = require("glob");

@@ -120,22 +121,44 @@ var mkdirp = require("mkdirp");

function deleteDir(dirToDelete) {
return fileOrFolderExists(dirToDelete).then(function (exists) {
if (exists) {
return readdir(dirToDelete).then(function (files) {
var promisses = files.map(function (file) {
var currentPath = path.join(dirToDelete, file);
return stats(currentPath).then(function (stats) {
if (stats.isDirectory()) {
// recursive
return deleteDir(currentPath);
}
else {
// delete file
return rmFile(currentPath);
}
});
});
// delete dir
return Promise.all(promisses).then(function () { return rmdir(dirToDelete); });
});
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
var exists, files, promisses;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fileOrFolderExists(dirToDelete)];
case 1:
exists = _a.sent();
if (!exists) return [3 /*break*/, 4];
return [4 /*yield*/, readdir(dirToDelete)];
case 2:
files = _a.sent();
promisses = files.map(function (file) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var currentPath, sts;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
currentPath = path.join(dirToDelete, file);
return [4 /*yield*/, stats(currentPath)];
case 1:
sts = _a.sent();
if (sts.isDirectory()) {
// recursive
return [2 /*return*/, deleteDir(currentPath)];
}
else {
// delete file
return [2 /*return*/, rmFile(currentPath)];
}
return [2 /*return*/];
}
});
}); });
// delete dir
return [4 /*yield*/, Promise.all(promisses)];
case 3:
// delete dir
_a.sent();
return [2 /*return*/, rmdir(dirToDelete)];
case 4: return [2 /*return*/];
}
});
});

@@ -145,11 +168,20 @@ }

function cleanFolder(folderName) {
return fileOrFolderExists(folderName)
.then(function (exists) {
if (exists) {
return deleteDir(folderName)
.then(function () { return mkdirRecursive(folderName); });
}
else {
return mkdirRecursive(folderName);
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var exists;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fileOrFolderExists(folderName)];
case 1:
exists = _a.sent();
if (!exists) return [3 /*break*/, 3];
return [4 /*yield*/, deleteDir(folderName)];
case 2:
_a.sent();
return [2 /*return*/, mkdirRecursive(folderName)];
case 3: return [2 /*return*/, mkdirRecursive(folderName)];
case 4:
;
return [2 /*return*/];
}
});
});

@@ -156,0 +188,0 @@ }

@@ -1,8 +0,8 @@

export declare var serialize: (obj: any) => string;
export declare const serialize: (obj: any) => string;
export declare function freezeRecursively(target: {
[customConfig: string]: any;
}): void;
export declare function isPromise(input: void | Promise<any>): input is Promise<any>;
export declare function isPromise(input: any): input is Promise<any>;
export declare function deserialize(serializedJavascript: String): any;
export declare function copy<T>(obj: T, deep?: boolean): T;
export declare function wrapInClosure(codeFragment: string): string;

@@ -5,3 +5,3 @@ /// <reference types="node" />

writeFile: (filename: string, data: string) => Promise<void>;
copyFile: (fromFilename: string, toFilename: string, instrumenter?: NodeJS.ReadWriteStream) => Promise<void>;
copyFile: (fromFilename: string, toFilename: string, instrumenter: NodeJS.ReadWriteStream | null) => Promise<void>;
ensureFolderExists: (path: string) => string;

@@ -8,0 +8,0 @@ clean: () => Promise<void>;

"use strict";
var fs = require("fs");
var fs = require("graceful-fs");
var path = require("path");

@@ -74,3 +74,3 @@ var mkdirp = require("mkdirp");

* @param toFilename The path to copy the file to.
* @param instrumenter An optional additional intrumenter to stream the file through
* @param instrumenter An optional additional instrumenter to stream the file through
* @returns A promise to eventually copy the file.

@@ -77,0 +77,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

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

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

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