Skip to content

Commit 5665a6a

Browse files
committed
* Removes build script from package.json
* Adds build script in make file * Removes un-used modules from package.json * Changes type of time_thrown and _showLocation * Gives default type as string to name parameter in constructor and createError * Removes unsued configurations from tsconfig
1 parent fbac46b commit 5665a6a

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endif
1313
.FORCE:
1414

1515
all: clean
16-
npm run build
16+
tsc
1717

1818
clean: .FORCE
1919
rimraf npm-debug.log dist

Diff for: dist/index.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "Machine-readable custom errors for Apollostack's GraphQL server",
55
"main": "dist/index.js",
66
"scripts": {
7-
"test": "make test",
8-
"build": "tsc"
7+
"test": "make test"
98
},
109
"repository": {
1110
"type": "git",
@@ -27,8 +26,7 @@
2726
"homepage": "https://github.com/thebigredgeek/apollo-errors#readme",
2827
"dependencies": {
2928
"assert": "^1.4.1",
30-
"extendable-error": "^0.1.5",
31-
"install": "^0.10.1"
29+
"extendable-error": "^0.1.5"
3230
},
3331
"devDependencies": {
3432
"babel-cli": "^6.18.0",
@@ -41,7 +39,6 @@
4139
"eslint-plugin-babel": "^3.3.0",
4240
"mocha": "^3.1.2",
4341
"rimraf": "^2.5.4",
44-
"typescript": "^2.5.2",
45-
"typings": "^2.1.1"
42+
"typescript": "^2.5.2"
4643
}
4744
}

Diff for: src/index.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import * as assert from 'assert';
22
import ExtendableError from 'extendable-error';
3+
34
const isString = d => Object.prototype.toString.call(d) === '[object String]';
45
const isObject = d => Object.prototype.toString.call(d) === '[object Object]';
6+
57
interface ErrorConfig {
68
message: string;
7-
time_thrown: any;
9+
time_thrown: string;
810
data: any,
911
options: any,
1012
}
13+
1114
class ApolloError extends ExtendableError {
1215
name: string;
1316
message: string;
14-
time_thrown: any;
17+
time_thrown: string;
1518
data: any;
1619
path: any;
1720
locations: any;
18-
_showLocations: any;
19-
constructor (name, config: ErrorConfig) {
20-
super((config && config.message) || '');
21+
_showLocations: boolean=false;
22+
23+
constructor (name:string, config: ErrorConfig) {
24+
super((arguments[2] && arguments[2].message) || '');
25+
2126
const t = (arguments[2] && arguments[2].time_thrown) || (new Date()).toISOString();
2227
const m = (arguments[2] && arguments[2].message) || '';
2328
const configData = (arguments[2] && arguments[2].data) || {};
@@ -51,7 +56,7 @@ class ApolloError extends ExtendableError {
5156

5257
export const isInstance = e => e instanceof ApolloError;
5358

54-
export const createError = (name, config: ErrorConfig) => {
59+
export const createError = (name:string, config: ErrorConfig) => {
5560
assert(isObject(config), 'createError requires a config object as the second parameter');
5661
assert(isString(config.message), 'createError requires a "message" property on the config object passed as the second parameter');
5762
const e = ApolloError.bind(null, name, config);

Diff for: test/spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('createError', () => {
1515
},
1616
options: {
1717
showLocations: false,
18-
showPath: false,
18+
showPath: true,
1919
},
2020
});
2121
const iso = new Date().toISOString();
@@ -27,7 +27,7 @@ describe('createError', () => {
2727
},
2828
options: {
2929
showLocations: true,
30-
showPath: true,
30+
showPath: false,
3131
},
3232
});
3333

Diff for: tsconfig.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"module": "commonjs",
55
"moduleResolution": "node",
66
"sourceMap": true,
7-
"emitDecoratorMetadata": true,
8-
"experimentalDecorators": true,
97
"removeComments": false,
108
"noImplicitAny": false,
119
"allowJs": true,

0 commit comments

Comments
 (0)