Skip to content

Commit

Permalink
feat(tsfmt): update dependencies, use npm-scripts for building
Browse files Browse the repository at this point in the history
  • Loading branch information
vvakame committed May 3, 2017
1 parent a49f094 commit 890836f
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 570 deletions.
71 changes: 2 additions & 69 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,8 @@
"use strict";

module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
opt: {
client: {
"tsMain": "lib",
"tsTest": "test",

"jsMainOut": "lib",
"jsTestOut": "test"
}
},

exec: {
tsc: "tsc -p ./"
},
tslint: {
options: {
configuration: "_tslint.json",
fix: true
},
files: {
src: [
'<%= opt.client.tsMain %>/**/*.ts',
'!<%= opt.client.tsMain %>/**/*.d.ts',
'<%= opt.client.tsTest %>/**/*.ts',
'!<%= opt.client.tsTest %>/**/*.ts' // TODO
]
}
},
clean: {
clientScript: {
src: [
// client
'<%= opt.client.tsMain %>/*.js',
'<%= opt.client.tsMain %>/*.js.map',
// client test
'<%= opt.client.tsTest %>/*.js',
'<%= opt.client.tsTest %>/*.js.map'
]
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
timeout: 20000,
require: [
function () {
require('espower-loader')({
cwd: process.cwd() + '/' + grunt.config.get("opt.client.jsTestOut"),
pattern: '**/*.js'
});
},
function () {
assert = require('power-assert');
}
]
},
src: [
'<%= opt.client.jsTestOut %>/**/*Spec.js'
]
}
},
conventionalChangelog: {
options: {
changelogOpts: {
Expand All @@ -87,13 +28,5 @@ module.exports = function (grunt) {
}
});

grunt.registerTask(
'default',
['clean:clientScript', 'exec:tsc', 'tslint']);

grunt.registerTask(
'test',
['default', 'mochaTest']);

require('load-grunt-tasks')(grunt);
};
1 change: 0 additions & 1 deletion _tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"no-switch-case-fall-through": false,
"no-trailing-whitespace": false,
"no-unused-expression": false,
"no-unused-new": false,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": false,
Expand Down
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"tsfmt": "./bin/tsfmt"
},
"scripts": {
"build": "grunt default",
"test": "grunt test"
"build": "tslint --fix --type-check -c _tslint.json -p tsconfig.json && tsfmt -r && tsc",
"test": "npm run build && mocha --reporter spec --timeout 20000 --require intelli-espower-loader"
},
"keywords": [
"TypeScript"
Expand Down Expand Up @@ -42,18 +42,14 @@
"@types/mocha": "^2.2.33",
"@types/node": "^7.0.5",
"@types/power-assert": "^1.4.29",
"espower-loader": "^1.2.0",
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-conventional-changelog": "^6.1.0",
"grunt-exec": "^1.0.1",
"grunt-mocha-test": "^0.13.2",
"grunt-tslint": "^4.0.1",
"intelli-espower-loader": "^1.0.1",
"load-grunt-tasks": "^3.5.0",
"mkdirp": "^0.5.1",
"mocha": "^3.0.2",
"power-assert": "^1.4.2",
"tslint": "^4.4.2",
"typescript": "^2.2.1"
"tslint": "^5.1.0",
"typescript": "^2.3.2"
}
}
10 changes: 5 additions & 5 deletions test/indexSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function exec(cmd: string, args: string[], options: childProcess.SpawnOptions):
resolve({
status: status,
stdout: stdout,
stderr: stderr
stderr: stderr,
});
});
});
Expand Down Expand Up @@ -161,7 +161,7 @@ describe("tsfmt test", () => {

return Promise.all([
checkByTslint(tslintConfigName, fileName, true),
checkByTslint(tslintConfigName, expectedTsFileName, false)
checkByTslint(tslintConfigName, expectedTsFileName, false),
]).then(() => null);
});
});
Expand Down Expand Up @@ -294,7 +294,7 @@ describe("tsfmt test", () => {

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

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

it("should pickup files from --useTsconfig specified tsconfig.json", () => {
return exec(path.resolve("./bin/tsfmt"), ["--verify", "--useTsconfig", "./tsconfig.main.json"], { cwd: path.resolve('./test/cli/useTsconfig') }).then(result => {
return exec(path.resolve("./bin/tsfmt"), ["--verify", "--useTsconfig", "./tsconfig.main.json"], { cwd: path.resolve("./test/cli/useTsconfig") }).then(result => {
assert.equal(result.status, 1);
assert.equal(result.stdout.trim(), "");
assert.equal(result.stderr.replace(process.cwd(), "**").trim(), `
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"node_modules",
"lib/*.d.ts",
"lib/provider/*.d.ts",
"test/cli",
"test/expected",
"test/fixture",
"example"
Expand Down
Loading

0 comments on commit 890836f

Please sign in to comment.