Skip to content

Commit d8f5670

Browse files
committed
feat(tsfmt): update dependencies, switch to typescript@1.6.2, change build process (tsconfig.json oriented)
1 parent ea4401c commit d8f5670

File tree

25 files changed

+923
-611
lines changed

25 files changed

+923
-611
lines changed

.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ typings/
1414
# codes
1515
test/
1616

17+
# for https://github.com/Microsoft/TypeScript/issues/4667
18+
lib/**/*.ts
19+
!lib/**/*.d.ts
20+
1721
# misc
1822
.gitignore
1923
.editorconfig

Gruntfile.js

+11-29
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,15 @@ module.exports = function (grunt) {
1212
},
1313

1414
ts: {
15-
options: {
16-
compile: true, // perform compilation. [true (default) | false]
17-
comments: true, // same as !removeComments. [true | false (default)]
18-
target: 'es5', // target javascript language. [es3 (default) | es5]
19-
module: 'commonjs', // target javascript module style. [amd (default) | commonjs]
20-
noImplicitAny: true,
21-
sourceMap: false, // generate a source map for every output js file. [true (default) | false]
22-
sourceRoot: '', // where to locate TypeScript files. [(default) '' == source ts location]
23-
mapRoot: '', // where to locate .map.js files. [(default) '' == generated js location.]
24-
declaration: true // generate a declaration .d.ts file for every output js file. [true | false (default)]
25-
},
26-
clientMain: {
27-
src: ['<%= opt.client.tsMain %>/cli.ts']
28-
},
29-
clientTest: {
30-
src: ['<%= opt.client.tsTest %>/indexSpec.ts']
15+
default: {
16+
tsconfig: {
17+
tsconfig: "./tsconfig.json",
18+
updateFiles:false
19+
}
20+
}
21+
},
22+
tsconfig: {
23+
main: {
3124
}
3225
},
3326
tslint: {
@@ -67,17 +60,6 @@ module.exports = function (grunt) {
6760
]
6861
}
6962
},
70-
dts_bundle: {
71-
build: {
72-
options: {
73-
name: "typescript-formatter",
74-
main: "lib/index.d.ts",
75-
baseDir: "",
76-
out: "typescript-formatter.d.ts",
77-
prefix: ''
78-
}
79-
}
80-
},
8163
mochaTest: {
8264
test: {
8365
options: {
@@ -131,11 +113,11 @@ module.exports = function (grunt) {
131113

132114
grunt.registerTask(
133115
'default',
134-
['clean:clientScript', 'ts:clientMain', 'tslint', 'dts_bundle']);
116+
['clean:clientScript', 'tsconfig', 'ts', 'tslint']);
135117

136118
grunt.registerTask(
137119
'test',
138-
['default', 'ts:clientTest', 'mochaTest']);
120+
['default', 'mochaTest']);
139121

140122
require('load-grunt-tasks')(grunt);
141123
};

dtsm.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
},
1515
"dependencies": {
1616
"node/node.d.ts": {
17-
"ref": "02271c53872b38f2f669f3162438c4c837a6fe20"
18-
},
19-
"es6-promise/es6-promise.d.ts": {
20-
"ref": "02271c53872b38f2f669f3162438c4c837a6fe20"
17+
"ref": "273a567b0a0bcc34cbf2a2470b2febc95796b644"
2118
},
2219
"mocha/mocha.d.ts": {
23-
"ref": "02271c53872b38f2f669f3162438c4c837a6fe20"
20+
"ref": "273a567b0a0bcc34cbf2a2470b2febc95796b644"
2421
},
2522
"power-assert/power-assert.d.ts": {
26-
"ref": "02271c53872b38f2f669f3162438c4c837a6fe20"
23+
"ref": "273a567b0a0bcc34cbf2a2470b2febc95796b644"
2724
}
2825
}
29-
}
26+
}

example/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path="../typescript-formatter.d.ts" />
2-
31
import tsfmt = require("typescript-formatter");
42

53
var result = tsfmt.processFiles(["./index.ts"], {

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./lib";

lib/cli.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/// <reference path="../typings/node/node.d.ts" />
2-
/// <reference path="../node_modules/commandpost/commandpost.d.ts" />
3-
41
require("es6-promise").polyfill();
52

63
import fs = require("fs");

lib/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/// <reference path="../typings/node/node.d.ts" />
2-
/// <reference path="../node_modules/typescript/bin/typescript.d.ts" />
3-
/// <reference path="../node_modules/typescript/bin/lib.es6.d.ts" />
4-
51
"use strict";
62

73
import ts = require("typescript");

lib/provider/base.ts

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface TsfmtSettings {
3535
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
3636
// かっこ内が空でない場合に始め括弧の後ろと終わりカッコの前にスペースを挿入する
3737
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
38+
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
3839
// 新しい行に関数の始め中括弧を配置する
3940
placeOpenBraceOnNewLineForFunctions?: boolean;
4041
// 新しい行にコントロールブロックの始め中括弧を配置する
@@ -75,6 +76,9 @@ export function makeFormatCodeOptions(fileName: string, options: ts.FormatCodeOp
7576
if (typeof config.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis === "boolean") {
7677
options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis = config.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis;
7778
}
79+
if (typeof config.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets === "boolean") {
80+
options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets = config.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets;
81+
}
7882
if (typeof config.placeOpenBraceOnNewLineForFunctions === "boolean") {
7983
options.PlaceOpenBraceOnNewLineForFunctions = config.placeOpenBraceOnNewLineForFunctions;
8084
}

lib/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function createDefaultFormatCodeOptions(): ts.FormatCodeOptions {
1616
InsertSpaceAfterKeywordsInControlFlowStatements: true,
1717
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
1818
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
19+
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
1920
PlaceOpenBraceOnNewLineForFunctions: false,
2021
PlaceOpenBraceOnNewLineForControlBlocks: false
2122
};

0 commit comments

Comments
 (0)