Skip to content

Refine dependencies #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// <reference path="../typings/tsd.d.ts" />
var ts = require("typescript");
var chai_1 = require("chai");
var fs = require("fs");
var _ = require("lodash");
var AssertionError = require("assertion-error");
var defaultCompilerOptions = {
noEmitOnError: true,
noImplicitAny: true,
Expand All @@ -13,7 +13,9 @@ function handleDiagnostics(type, diagnostics) {
diagnostics.forEach(function (diagnostic) {
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
chai_1.assert.fail(diagnostic, undefined, type + ": " + diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message);
throw new AssertionError(type + ": " + diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message, {
actual: diagnostic
});
});
}
function compile(fileNames, options, done) {
Expand Down Expand Up @@ -42,7 +44,9 @@ function compileDirectory(path, filter, options, done) {
options = _.merge(defaultCompilerOptions, (options || {}));
walk(path, filter, function (err, results) {
if (err) {
chai_1.assert.fail(err, undefined, 'Error while walking directory for files.');
throw new AssertionError('Error while walking directory for files.', {
actual: err
});
done();
}
else {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
"license": "MIT",
"devDependencies": {
"bluebird": "^2.9.24",
"chai": "^2.2.0",
"typescript": "^1.5.0-alpha"
},
"typescript": {
"definition": "./dist/typescript-definition-tester.d.ts"
},
"dependencies": {
"assertion-error": "^1.0.1",
"dts-bundle": "^0.2.0",
"lodash": "^3.6.0"
},
"peerDependencies": {
"typescript": "1.x"
}
}
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/// <reference path="../typings/tsd.d.ts" />

import * as ts from "typescript";
import * as chai from "chai";
import {assert} from "chai";
import * as fs from "fs";
import * as _ from "lodash";
import AssertionError = require("assertion-error");

var defaultCompilerOptions = {
noEmitOnError: true,
Expand All @@ -17,8 +16,9 @@ function handleDiagnostics(type: string, diagnostics: ts.Diagnostic[]) {
diagnostics.forEach(diagnostic => {
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');

assert.fail(diagnostic, undefined, `${type}: ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
throw new AssertionError(`${type}: ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`, {
actual: diagnostic
});
});
}

Expand Down Expand Up @@ -55,7 +55,9 @@ export function compileDirectory(path: string, filter?: any, options?: any, done

walk(path, filter, (err, results) => {
if (err) {
assert.fail(err, undefined, 'Error while walking directory for files.');
throw new AssertionError('Error while walking directory for files.', {
actual: err
});
done();
} else {
compile(results, options, done);
Expand Down Expand Up @@ -96,4 +98,4 @@ export function walk(dir: string, filter?: (fileName: string) => boolean, done?:
});
})();
});
};
};
3 changes: 1 addition & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import * as ts from "typescript";
import * as tt from "../src/index";
import * as fs from "fs";
import * as chai from "chai";

describe('ambient declaration tests', () => {
it('should compile examples successfully against typescript-definition-tester.d.ts', (done) => {
Expand All @@ -13,4 +12,4 @@ describe('ambient declaration tests', () => {
() => done()
);
});
});
});
6 changes: 3 additions & 3 deletions tsd.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"typescript/typescript.d.ts": {
"commit": "8f16b0fd1acd81a555b74f912da849dccc7c9a42"
},
"chai/chai.d.ts": {
"commit": "8f16b0fd1acd81a555b74f912da849dccc7c9a42"
},
"mocha/mocha.d.ts": {
"commit": "8f16b0fd1acd81a555b74f912da849dccc7c9a42"
},
Expand All @@ -22,6 +19,9 @@
},
"lodash/lodash.d.ts": {
"commit": "8f16b0fd1acd81a555b74f912da849dccc7c9a42"
},
"assertion-error/assertion-error.d.ts": {
"commit": "99c4fb76b5d941939ba53e61d0daee4bd74f150f"
}
}
}
15 changes: 15 additions & 0 deletions typings/assertion-error/assertion-error.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Type definitions for assertion-error 1.0.0
// Project: https://github.com/chaijs/assertion-error
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

declare module 'assertion-error' {
class AssertionError implements Error {
constructor(message: string, props?: any, ssf?: Function);
name: string;
message: string;
showDiff: boolean;
stack: string;
}
export = AssertionError;
}
Loading