Skip to content

Commit fb469e7

Browse files
committed
Update build for node 6 to allow private package
1 parent 17281d0 commit fb469e7

10 files changed

Lines changed: 1670 additions & 1665 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ install:
2323
- npm uninstall typescript --no-save
2424
- npm uninstall tslint --no-save
2525
- npm install
26+
- if [ "$TRAVIS_NODE_VERSION" = "6" ]; then
27+
npm uninstall typemock --no-save;
28+
npm run build:typemock;
29+
npm install file:scripts/typemock --no-save;
30+
fi
2631

2732
cache:
2833
directories:

Gulpfile.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,15 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
608608
return runSequence("LKGInternal", "VerifyLKG");
609609
});
610610

611-
// NOTE: This build task is currently commented out as the approach to including typemock as a private
612-
// package does not seem to work in Node 6. If this issue cannot be resolved, this will be removed.
613-
//// gulp.task("typemock", () => {
614-
//// const typemock = tsc.createProject("scripts/typemock/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
615-
//// return typemock.src()
616-
//// .pipe(sourcemaps.init())
617-
//// .pipe(newer("scripts/typemock/dist"))
618-
//// .pipe(typemock())
619-
//// .pipe(sourcemaps.write(".", <any>{ includeContent: false, destPath: "scripts/typemock/dist" }))
620-
//// .pipe(gulp.dest("scripts/typemock/dist"));
621-
//// });
622-
gulp.task("typemock");
611+
gulp.task("typemock", () => {
612+
const typemock = tsc.createProject("scripts/typemock/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ false));
613+
return typemock.src()
614+
.pipe(sourcemaps.init())
615+
.pipe(newer("scripts/typemock/dist"))
616+
.pipe(typemock())
617+
.pipe(sourcemaps.write(".", <any>{ includeContent: false, destPath: "scripts/typemock/dist" }))
618+
.pipe(gulp.dest("scripts/typemock/dist"));
619+
});
623620

624621
// Task to build the tests infrastructure using the built compiler
625622
const run = path.join(builtLocalDirectory, "run.js");

Jakefile.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -779,21 +779,18 @@ task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
779779
// Test directory
780780
directory(builtLocalDirectory);
781781

782-
// NOTE: This build task is currently commented out as the approach to including typemock as a private
783-
// package does not seem to work in Node 6. If this issue cannot be resolved, this will be removed.
784-
//// task("typemock", function () {
785-
//// var startCompileTime = mark();
786-
//// execCompiler(/*useBuiltCompiler*/ true, ["-p", "scripts/typemock/tsconfig.json"], function (error) {
787-
//// if (error) {
788-
//// fail("Compilation unsuccessful.");
789-
//// }
790-
//// else {
791-
//// complete();
792-
//// }
793-
//// measure(startCompileTime);
794-
//// });
795-
//// }, { async: true });
796-
task("typemock");
782+
task("typemock", function () {
783+
var startCompileTime = mark();
784+
execCompiler(/*useBuiltCompiler*/ false, ["-p", "scripts/typemock/tsconfig.json"], function (error) {
785+
if (error) {
786+
fail("Compilation unsuccessful.");
787+
}
788+
else {
789+
complete();
790+
}
791+
measure(startCompileTime);
792+
});
793+
}, { async: true });
797794

798795
// Task to build the tests infrastructure using the built compiler
799796
var run = path.join(builtLocalDirectory, "run.js");

jenkins.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,13 @@ nvm install $1
99
npm uninstall typescript --no-save
1010
npm uninstall tslint --no-save
1111
npm install
12+
13+
# Node 6 uses an older version of npm that does not symlink a package with a "file:" reference
14+
if [ "$1" = "6" ]; then
15+
npm uninstall typemock --no-save;
16+
npm run build:typemock;
17+
npm install file:scripts/typemock --no-save;
18+
fi
19+
1220
npm update
1321
npm test

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"build": "npm run build:compiler && npm run build:tests",
9292
"build:compiler": "jake local",
9393
"build:tests": "jake tests",
94+
"build:typemock": "jake typemock",
9495
"start": "node lib/tsc",
9596
"clean": "jake clean",
9697
"gulp": "gulp",

scripts/typemock/src/arg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class Arg {
114114
public static includes(value: string): string & string[] & Arg;
115115
public static includes<T>(value: T): T[] & Arg;
116116
public static includes<T>(value: T): Arg {
117-
return new Arg(value_ => Array.isArray(value_) ? value_.includes(value) : typeof value_ === "string" && value_.includes("" + value), `contains ${value}`);
117+
return new Arg(value_ => Array.isArray(value_) ? value_.indexOf(value) >= 0 : typeof value_ === "string" && value_.includes("" + value), `contains ${value}`);
118118
}
119119

120120
public static array<T>(values: (T | T & Arg)[]): T[] & Arg {

scripts/typemock/src/mock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class Mock<T extends object> {
174174
if (times === undefined) {
175175
times = Times.atLeastOnce();
176176
}
177-
this._handler.verify(callback, times);
177+
this._handler.verify(callback, times, message);
178178
return this;
179179
}
180180

@@ -294,7 +294,7 @@ class Recording {
294294
public match(trap: string, name: PropertyKey | undefined, thisArg: any, argArray: any, newTarget: any) {
295295
return this.trap === trap
296296
&& this.name === name
297-
&& Arg.validate(this.thisCondition, thisArg)
297+
&& this.matchThisArg(thisArg)
298298
&& Arg.validateAll(this.argConditions, argArray)
299299
&& Arg.validate(this.newTargetCondition, newTarget);
300300
}

scripts/typemock/src/tests/mockTests.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import "./sourceMapSupport";
22
import { Mock } from "../mock";
3-
import { Inject } from "../inject";
43
import { Arg } from "../arg";
54
import { Times } from "../times";
65
import { recordError } from "./utils";
@@ -107,7 +106,7 @@ describe("mock", () => {
107106
// arrange
108107
const target = { a: 1 };
109108
const error = new Error("error");
110-
const mock = new Mock(target, { set a(value: number) { throw error; } });
109+
const mock = new Mock(target, { set a(_: number) { throw error; } });
111110

112111
// act
113112
const e = recordError(() => mock.proxy.a = 2);
@@ -218,7 +217,7 @@ describe("mock", () => {
218217
});
219218
it("function", () => {
220219
// arrange
221-
const mock = new Mock<(x: number) => number>(x => 0);
220+
const mock = new Mock<(x: number) => number>(_ => 0);
222221
mock.setup(_ => _(Arg.number()), { return: 2 });
223222

224223
// act
@@ -248,7 +247,7 @@ describe("mock", () => {
248247
// arrange
249248
const target = { a: 1 };
250249
const mock = new Mock(target);
251-
const result = mock.proxy.a;
250+
mock.proxy.a;
252251

253252
// act
254253
const e = recordError(() => mock.verify(_ => _.a, Times.once()));
@@ -298,7 +297,7 @@ describe("mock", () => {
298297
// arrange
299298
const target = { a() { return 1; } };
300299
const mock = new Mock(target);
301-
const result = mock.proxy.a();
300+
mock.proxy.a();
302301

303302
// act
304303
const e = recordError(() => mock.verify(_ => _.a(), Times.once()));
@@ -321,7 +320,7 @@ describe("mock", () => {
321320
it("called passes", () => {
322321
// arrange
323322
const mock = Mock.function();
324-
const result = mock.proxy();
323+
mock.proxy();
325324

326325
// act
327326
const e = recordError(() => mock.verify(_ => _(), Times.once()));
@@ -335,7 +334,7 @@ describe("mock", () => {
335334
// arrange
336335
const target = { a: 1 };
337336
const mock = new Mock(target, { get a() { return 2 } });
338-
const result = mock.proxy.a;
337+
mock.proxy.a;
339338

340339
// act
341340
const e = recordError(() => mock.verify(_ => _.a, Times.once()));
@@ -351,7 +350,7 @@ describe("mock", () => {
351350
return x + 2;
352351
}
353352
});
354-
const result = mock.proxy.a(3);
353+
mock.proxy.a(3);
355354

356355
// act
357356
const e = recordError(() => mock.verify(_ => _.a(Arg.number()), Times.once()));

scripts/typemock/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"compilerOptions": {
33
"module": "commonjs",
4-
"target": "es2017",
4+
"target": "es2015",
55
"strict": true,
66
"declaration": true,
77
"sourceMap": true,
8+
"noUnusedLocals": true,
9+
"noUnusedParameters": true,
810
"types": ["mocha"],
911
"newLine": "LF",
1012
"outDir": "dist"

0 commit comments

Comments
 (0)