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

definition-tester

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

definition-tester - npm Package Compare versions

Comparing version

to
2.0.5-alpha

3

package.json
{
"name": "definition-tester",
"version": "2.0.4-alpha",
"version": "2.0.5-alpha",
"description": "DefinitelyTyped repository testing infrastructure",

@@ -40,3 +40,2 @@ "keywords": [

"findup-sync": "^0.3.0",
"git-wrapper": "^0.1.1",
"glob": "^7.0.3",

@@ -43,0 +42,0 @@ "lazy.js": "^0.4.2",

@@ -68,3 +68,3 @@ 'use strict';

}).uniq().each(function (local) {
var full = util.fixPath(path.resolve(_this.options.dtPath, local));
var full = path.resolve(_this.options.dtPath, local);
var file = _this.getFile(full);

@@ -71,0 +71,0 @@ if (!file) {

@@ -7,3 +7,2 @@ 'use strict';

var findup = require('findup-sync');
var util = require('./util/util');
var TestRunner_1 = require('./test/TestRunner');

@@ -54,3 +53,3 @@ Promise.longStackTraces();

}
var dtPath = util.fixPath(path.resolve(argv['path']));
var dtPath = path.resolve(argv['path']);
var cpuCores = os.cpus().length;

@@ -68,3 +67,3 @@ if (argv.help) {

new TestRunner_1.default({
testerPath: util.fixPath(path.dirname(testerPkgPath)),
testerPath: path.dirname(testerPkgPath),
dtPath: dtPath,

@@ -71,0 +70,0 @@ concurrent: (argv['single-thread'] ? 1 : Math.round(cpuCores * .75)),

@@ -71,3 +71,3 @@ 'use strict';

return new Promise(function (resolve) {
_this.getTestsToRun().done(function (testsToRun) {
return _this.getTestsToRun().done(function (testsToRun) {
if (_this.options.printRefMap) {

@@ -84,7 +84,7 @@ _this.print.printRefMap(_this.index, _this.index.refMap);

}
_this.runTests(testsToRun.map(function (test) { return File_1.default.fromFullPath(test); })).then(function () {
resolve(_this.runTests(testsToRun.map(function (test) { return File_1.default.fromFullPath(test); })).then(function () {
return !_this.suites.some(function (suite) {
return suite.ngTests.length !== 0;
});
});
}));
});

@@ -110,7 +110,7 @@ });

}
return Promise.reduce(_this.suites, function (count, suite) {
resolve(Promise.reduce(_this.suites, function (count, suite) {
suite.testReporter = suite.testReporter || new DefaultReporter_1.default(_this.print);
_this.print.printSuiteHeader(suite.testSuiteName);
if (suite.testSuiteName === 'Header format') {
_this.getTsFiles().done(function (tsFiles) {
return _this.getTsFiles().then(function (tsFiles) {
return suite.start((tsFiles.filter(isEntryPointFile)).map(function (test) { return File_1.default.fromFullPath(test); }), function (testResult) {

@@ -120,3 +120,3 @@ _this.print.printTestComplete(testResult);

_this.print.printSuiteComplete(suite);
return count++;
return count + 1;
});

@@ -130,6 +130,6 @@ });

_this.print.printSuiteComplete(suite);
return count++;
return count + 1;
});
}
}, 0);
}, 0));
}).then(function (count) {

@@ -136,0 +136,0 @@ _this.timer.end();

import * as Promise from 'bluebird';
import { ITscExecOptions } from './ITscExecOptions';
export default class Tsc {
static useJsx: RegExp;
static run(tsConfigfile: string, options: ITscExecOptions): Promise<string[]>;
}
export default function runTsc(tsConfigfile: string, options: ITscExecOptions): Promise<string[]>;

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

var Promise = require('bluebird');
var exec_1 = require('../util/exec');
var util = require('../util/util');
var ts = require('typescript');
var lastOpts = {};
var lastProgram = undefined;
function diagsToStrings(diags) {

@@ -16,58 +15,60 @@ return diags.map(function (d) {

}
var Tsc = (function () {
function Tsc() {
}
Tsc.run = function (tsConfigfile, options) {
var tscPath = options.tscPath;
return Promise.all([
util.fileExists(tsConfigfile),
util.fileExists(tscPath)
]).spread(function (tsfileExists, tscPathExists) {
if (!tsfileExists) {
throw new Error(tsConfigfile + ' does not exist in path ' + tscPath);
var useJsx = /\.tsx$/i;
function runTsc(tsConfigfile, options) {
var tscPath = options.tscPath;
var root = path.dirname(tsConfigfile);
return Promise.all([
util.fileExists(tsConfigfile),
util.fileExists(tscPath),
util.fileExists(path.join(root, 'package.json'))
]).spread(function (tsfileExists, tscPathExists, packageExists) {
if (!tsfileExists) {
throw new Error(tsConfigfile + ' does not exist in path ' + tscPath);
}
if (!tscPathExists) {
throw new Error(tscPath + ' does not exist in path ' + tscPath);
}
return packageExists ? installNodeModules(root) : undefined;
}).then(function () {
var configJson = ts.parseConfigFileTextToJson('tsconfig.json', fs.readFileSync(tsConfigfile, 'utf-8'));
var configParse = ts.parseJsonConfigFileContent(configJson.config, ts.sys, root, undefined, tsConfigfile);
var opts = configParse.options;
if (opts === undefined) {
throw new Error('Failed when parsing ' + tsConfigfile);
}
var diagnostics = [];
var oldCwd = process.cwd();
process.chdir(root);
try {
var program = ts.createProgram(configParse.fileNames, opts);
addDiagnostics(program.getGlobalDiagnostics());
addDiagnostics(program.getSyntacticDiagnostics());
addDiagnostics(program.getSemanticDiagnostics());
}
finally {
process.chdir(oldCwd);
}
var result = diagsToStrings(diagnostics);
if (result.length > 0) {
console.log("== Errors when compiling " + tsConfigfile + " ==");
console.log(result.join('\r\n'));
}
return result;
function addDiagnostics(diags) {
if (diags && diags.length) {
diagnostics = diagnostics.concat(diags);
}
if (!tscPathExists) {
throw new Error(tscPath + ' does not exist in path ' + tscPath);
}
return true;
}).then(function (ok) {
var root = path.dirname(tsConfigfile);
var configJson = ts.parseConfigFileTextToJson('tsconfig.json', fs.readFileSync(tsConfigfile, 'utf-8'));
var configParse = ts.parseJsonConfigFileContent(configJson.config, ts.sys, root, undefined, tsConfigfile);
var opts = configParse.options;
if (opts === undefined) {
throw new Error('Failed when parsing ' + tsConfigfile);
}
var diagnostics = [];
var oldCwd = process.cwd();
process.chdir(root);
try {
lastProgram = ts.createProgram(configParse.fileNames, opts);
lastOpts = opts;
var program = lastProgram;
addDiagnostics(program.getGlobalDiagnostics());
addDiagnostics(program.getSyntacticDiagnostics());
addDiagnostics(program.getSemanticDiagnostics());
}
finally {
process.chdir(oldCwd);
}
var result = diagsToStrings(diagnostics);
if (result.length > 0) {
console.log("== Errors when compiling " + tsConfigfile + " ==");
console.log(result.join('\r\n'));
}
return result;
function addDiagnostics(diags) {
if (diags && diags.length) {
diagnostics = diagnostics.concat(diags);
}
}
});
};
Tsc.useJsx = /\.tsx$/i;
return Tsc;
}());
}
});
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Tsc;
exports.default = runTsc;
function installNodeModules(cwd) {
return exec_1.exec('npm install', [], cwd).then(function (_a) {
var error = _a.error, exitCode = _a.exitCode, stdout = _a.stdout, stderr = _a.stderr;
if (error) {
throw error;
}
});
}
//# sourceMappingURL=Tsc.js.map

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

var _this = this;
return Tsc_1.default.run(this.tsConfigFile.fullPath, this.options).then(function (diagnostics) {
return Tsc_1.default(this.tsConfigFile.fullPath, this.options).then(function (diagnostics) {
var testResult = new TestResult_1.default();

@@ -15,0 +15,0 @@ testResult.hostedBy = _this.suite;

@@ -8,2 +8,2 @@ import * as Promise from 'bluebird';

}
export declare function exec(filename: string, cmdLineArgs: string[]): Promise<ExecResult>;
export declare function exec(commandName: string, cmdLineArgs: string[], cwd?: string): Promise<ExecResult>;

@@ -12,8 +12,8 @@ 'use strict';

exports.ExecResult = ExecResult;
function exec(filename, cmdLineArgs) {
function exec(commandName, cmdLineArgs, cwd) {
return new Promise(function (resolve, reject) {
var result = new ExecResult();
result.exitCode = null;
var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
var cp = child_process.exec(cmdLine, { maxBuffer: 1 * 1024 * 1024 }, function (error, stdout, stderr) {
var cmdLine = commandName + ' ' + cmdLineArgs.join(' ');
var cp = child_process.exec(cmdLine, { cwd: cwd, maxBuffer: 1 * 1024 * 1024 }, function (error, stdout, stderr) {
result.error = error;

@@ -20,0 +20,0 @@ result.stdout = String(stdout);

'use strict';
var child_process = require('child_process');
var path = require('path');
var Git = require('git-wrapper');
var Promise = require('bluebird');

@@ -11,2 +11,3 @@ var util = require('./util');

GitChanges.prototype.readChanges = function () {
var _this = this;
var dir = path.join(this.dtPath, '.git');

@@ -18,8 +19,3 @@ return util.fileExists(dir).then(function (exists) {

return new Promise(function (resolve, reject) {
var args = ['--name-only HEAD~1'];
var opts = {};
var git = new Git({
'git-dir': dir
});
git.exec('diff', opts, args, function (err, msg) {
child_process.exec('git diff --name-only HEAD~1', { cwd: _this.dtPath }, function (err, stdout, stderr) {
if (err) {

@@ -29,3 +25,4 @@ reject(err);

else {
resolve(msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g));
var msg = stdout;
resolve(msg.trim().split(/\r?\n/g));
}

@@ -37,5 +34,10 @@ });

GitChanges.prototype.readChangedFolders = function () {
var _this = this;
return this.readChanges().then(function (changes) {
return util.filterAsync(util.unique(changes.map(path.dirname)), function (folder) {
return Promise.resolve(folder !== '.' && util.fileExists(folder));
return util.filterMapAsync(util.unique(changes.map(rootDirName)), function (folder) {
if (folder === '.') {
return undefined;
}
var full = path.join(_this.dtPath, folder);
return util.fileExists(full).then(function (exists) { return exists ? full : undefined; });
});

@@ -48,2 +50,6 @@ });

exports.default = GitChanges;
function rootDirName(fileName) {
var slash = fileName.indexOf('/');
return slash === -1 ? fileName : fileName.slice(0, slash);
}
//# sourceMappingURL=GitChanges.js.map

@@ -15,4 +15,3 @@ import * as Promise from 'bluebird';

export declare function readJSON(target: string): Promise<string>;
export declare function fixPath(str: string): string;
export declare function filterAsync<T>(arr: T[], shouldKeep: (t: T) => Promise<boolean>): Promise<T[]>;
export declare function filterMapAsync<T>(arr: T[], filterMap: (t: T) => Promise<T | undefined>): Promise<T[]>;
export declare function unique(arr: string[]): string[];

@@ -66,14 +66,15 @@ 'use strict';

exports.readJSON = readJSON;
function fixPath(str) {
return str.replace(/^[a-z]:/i, function (s) {
return s.toLowerCase();
function filterMapAsync(arr, filterMap) {
return Promise.all(arr.map(filterMap)).then(function (ts) {
var out = [];
for (var _i = 0, ts_1 = ts; _i < ts_1.length; _i++) {
var t = ts_1[_i];
if (t !== undefined) {
out.push(t);
}
}
return out;
});
}
exports.fixPath = fixPath;
function filterAsync(arr, shouldKeep) {
return Promise.all(arr.map(shouldKeep)).then(function (shouldKeeps) {
return arr.filter(function (_, idx) { return shouldKeeps[idx]; });
});
}
exports.filterAsync = filterAsync;
exports.filterMapAsync = filterMapAsync;
function unique(arr) {

@@ -80,0 +81,0 @@ var set = {};

@@ -62,3 +62,2 @@ {

"./typings/fixes.d.ts",
"./typings/git-wrapper/git-wrapper.d.ts",
"./typings/glob/glob.d.ts",

@@ -65,0 +64,0 @@ "./typings/lazy.js/lazy.js.d.ts",

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