Skip to content

Commit 890836f

Browse files
committed
feat(tsfmt): update dependencies, use npm-scripts for building
1 parent a49f094 commit 890836f

File tree

6 files changed

+200
-570
lines changed

6 files changed

+200
-570
lines changed

Gruntfile.js

+2-69
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,8 @@
1+
"use strict";
2+
13
module.exports = function (grunt) {
24
grunt.initConfig({
35
pkg: grunt.file.readJSON('package.json'),
4-
opt: {
5-
client: {
6-
"tsMain": "lib",
7-
"tsTest": "test",
8-
9-
"jsMainOut": "lib",
10-
"jsTestOut": "test"
11-
}
12-
},
13-
14-
exec: {
15-
tsc: "tsc -p ./"
16-
},
17-
tslint: {
18-
options: {
19-
configuration: "_tslint.json",
20-
fix: true
21-
},
22-
files: {
23-
src: [
24-
'<%= opt.client.tsMain %>/**/*.ts',
25-
'!<%= opt.client.tsMain %>/**/*.d.ts',
26-
'<%= opt.client.tsTest %>/**/*.ts',
27-
'!<%= opt.client.tsTest %>/**/*.ts' // TODO
28-
]
29-
}
30-
},
31-
clean: {
32-
clientScript: {
33-
src: [
34-
// client
35-
'<%= opt.client.tsMain %>/*.js',
36-
'<%= opt.client.tsMain %>/*.js.map',
37-
// client test
38-
'<%= opt.client.tsTest %>/*.js',
39-
'<%= opt.client.tsTest %>/*.js.map'
40-
]
41-
}
42-
},
43-
mochaTest: {
44-
test: {
45-
options: {
46-
reporter: 'spec',
47-
timeout: 20000,
48-
require: [
49-
function () {
50-
require('espower-loader')({
51-
cwd: process.cwd() + '/' + grunt.config.get("opt.client.jsTestOut"),
52-
pattern: '**/*.js'
53-
});
54-
},
55-
function () {
56-
assert = require('power-assert');
57-
}
58-
]
59-
},
60-
src: [
61-
'<%= opt.client.jsTestOut %>/**/*Spec.js'
62-
]
63-
}
64-
},
656
conventionalChangelog: {
667
options: {
678
changelogOpts: {
@@ -87,13 +28,5 @@ module.exports = function (grunt) {
8728
}
8829
});
8930

90-
grunt.registerTask(
91-
'default',
92-
['clean:clientScript', 'exec:tsc', 'tslint']);
93-
94-
grunt.registerTask(
95-
'test',
96-
['default', 'mochaTest']);
97-
9831
require('load-grunt-tasks')(grunt);
9932
};

_tslint.json

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
"no-switch-case-fall-through": false,
7272
"no-trailing-whitespace": false,
7373
"no-unused-expression": false,
74-
"no-unused-new": false,
7574
"no-use-before-declare": true,
7675
"no-var-keyword": true,
7776
"no-var-requires": false,

package.json

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"tsfmt": "./bin/tsfmt"
88
},
99
"scripts": {
10-
"build": "grunt default",
11-
"test": "grunt test"
10+
"build": "tslint --fix --type-check -c _tslint.json -p tsconfig.json && tsfmt -r && tsc",
11+
"test": "npm run build && mocha --reporter spec --timeout 20000 --require intelli-espower-loader"
1212
},
1313
"keywords": [
1414
"TypeScript"
@@ -42,18 +42,14 @@
4242
"@types/mocha": "^2.2.33",
4343
"@types/node": "^7.0.5",
4444
"@types/power-assert": "^1.4.29",
45-
"espower-loader": "^1.2.0",
4645
"grunt": "^1.0.1",
47-
"grunt-contrib-clean": "^1.0.0",
4846
"grunt-conventional-changelog": "^6.1.0",
49-
"grunt-exec": "^1.0.1",
50-
"grunt-mocha-test": "^0.13.2",
51-
"grunt-tslint": "^4.0.1",
47+
"intelli-espower-loader": "^1.0.1",
5248
"load-grunt-tasks": "^3.5.0",
5349
"mkdirp": "^0.5.1",
5450
"mocha": "^3.0.2",
5551
"power-assert": "^1.4.2",
56-
"tslint": "^4.4.2",
57-
"typescript": "^2.2.1"
52+
"tslint": "^5.1.0",
53+
"typescript": "^2.3.2"
5854
}
5955
}

test/indexSpec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function exec(cmd: string, args: string[], options: childProcess.SpawnOptions):
4444
resolve({
4545
status: status,
4646
stdout: stdout,
47-
stderr: stderr
47+
stderr: stderr,
4848
});
4949
});
5050
});
@@ -161,7 +161,7 @@ describe("tsfmt test", () => {
161161

162162
return Promise.all([
163163
checkByTslint(tslintConfigName, fileName, true),
164-
checkByTslint(tslintConfigName, expectedTsFileName, false)
164+
checkByTslint(tslintConfigName, expectedTsFileName, false),
165165
]).then(() => null);
166166
});
167167
});
@@ -294,7 +294,7 @@ describe("tsfmt test", () => {
294294

295295
describe("CLI test", () => {
296296
it("should reformat files specified at files in tsconfig.json", () => {
297-
return exec(path.resolve("./bin/tsfmt"), [], { cwd: path.resolve('./test/cli/files') }).then(result => {
297+
return exec(path.resolve("./bin/tsfmt"), [], { cwd: path.resolve("./test/cli/files") }).then(result => {
298298
assert.equal(result.status, 0);
299299
assert.equal(result.stdout.trim(), `
300300
class TestCLI {
@@ -307,7 +307,7 @@ class TestCLI {
307307
});
308308

309309
it("should reformat files specified at include, exclude in tsconfig.json", () => {
310-
return exec(path.resolve("./bin/tsfmt"), [], { cwd: path.resolve('./test/cli/includeExclude') }).then(result => {
310+
return exec(path.resolve("./bin/tsfmt"), [], { cwd: path.resolve("./test/cli/includeExclude") }).then(result => {
311311
assert.equal(result.status, 0);
312312
assert.equal(result.stdout.trim(), `
313313
export class TestCLI {
@@ -319,7 +319,7 @@ export class TestCLI {
319319
});
320320

321321
it("should pickup files from --useTsconfig specified tsconfig.json", () => {
322-
return exec(path.resolve("./bin/tsfmt"), ["--verify", "--useTsconfig", "./tsconfig.main.json"], { cwd: path.resolve('./test/cli/useTsconfig') }).then(result => {
322+
return exec(path.resolve("./bin/tsfmt"), ["--verify", "--useTsconfig", "./tsconfig.main.json"], { cwd: path.resolve("./test/cli/useTsconfig") }).then(result => {
323323
assert.equal(result.status, 1);
324324
assert.equal(result.stdout.trim(), "");
325325
assert.equal(result.stderr.replace(process.cwd(), "**").trim(), `

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"node_modules",
4242
"lib/*.d.ts",
4343
"lib/provider/*.d.ts",
44+
"test/cli",
4445
"test/expected",
4546
"test/fixture",
4647
"example"

0 commit comments

Comments
 (0)