Skip to content

Commit 67b6cbc

Browse files
committed
ts compiler setup
1 parent 5301fbf commit 67b6cbc

File tree

5 files changed

+172
-30
lines changed

5 files changed

+172
-30
lines changed

src/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Test
2+
This is a test

src/build.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
1-
// JSON.stringify
2-
3-
function line(char, times) {
4-
return new RegExp("^" + char + "{" + times + "}(?!#)(.*?)$","g");
5-
}
6-
7-
var regex = {
8-
'#': line('#', 1),
9-
'##': line('#', 2),
10-
'###': line('#', 3)
11-
};
12-
13-
function parseWithCode(code, content) {
14-
return regex[code].exec(content)[1];
15-
}
16-
17-
// #
18-
19-
20-
// ##
21-
22-
// ###
23-
24-
// +
25-
26-
// @test
27-
28-
// @action
29-
30-
// @hint
1+
var fs = require('fs');
2+
function line(char, times) {
3+
return new RegExp('^' + char + '{' + times + '}(?!#)(.*?)$', 'gm');
4+
}
5+
var regex = {
6+
'#': line('#', 1),
7+
'##': line('#', 2),
8+
'###': line('#', 3),
9+
'+': line('\\+', 1)
10+
};
11+
function parseWithCode(code, content) {
12+
return regex[code].exec(content)[1];
13+
}
14+
fs.readFile('./src/README.md', 'utf8', function (err, data) {
15+
if (err) {
16+
console.log(err);
17+
}
18+
console.log(data);
19+
});
20+
function build() {
21+
var result = {
22+
project: {},
23+
chapters: []
24+
};
25+
return result;
26+
}
27+
build();

src/build.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
var fs = require('fs');
2+
// JSON.stringify
3+
4+
function line(char: string, times: number) {
5+
return new RegExp('^' + char + '{' + times + '}(?!#)(.*?)$', 'gm');
6+
}
7+
8+
var regex = {
9+
'#': line('#', 1),
10+
'##': line('#', 2),
11+
'###': line('#', 3),
12+
'+': line('\\+', 1)
13+
};
14+
15+
function parseWithCode(code: string, content: string) {
16+
return regex[code].exec(content)[1];
17+
}
18+
19+
fs.readFile('./src/README.md', 'utf8', function(err, data) {
20+
if (err) {
21+
console.log(err);
22+
}
23+
console.log(data);
24+
// resolve(data.split('\n'));
25+
});
26+
27+
function build() {
28+
var result = {
29+
project: {},
30+
chapters: []
31+
};
32+
33+
// load data from file into array
34+
35+
36+
// data.forEach(function(line) {
37+
// console.log(line);
38+
// })
39+
40+
// result.project.title = parseWithCode('#', content);
41+
// result.project.description = '';
42+
43+
return result;
44+
}
45+
46+
build();
47+
48+
// #
49+
50+
51+
// ##
52+
53+
// ###
54+
55+
// +
56+
57+
// @test
58+
59+
// @action
60+
61+
// @hint

tsconfig.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "commonjs"
5+
},
6+
"compileOnSave": true,
7+
"buildOnSave": true,
8+
"filesGlob": [
9+
"src/**/*.ts"
10+
],
11+
"files": [
12+
"src/build.ts"
13+
],
14+
"exclude": [
15+
"node_modules"
16+
],
17+
"atom": {
18+
"rewriteTsconfig": true
19+
}
20+
}

tslint.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"rules": {
3+
"class-name": true,
4+
"comment-format": [true, "check-space"],
5+
"curly": true,
6+
"eofline": true,
7+
"forin": true,
8+
"indent": [true, "spaces"],
9+
"label-position": true,
10+
"label-undefined": true,
11+
"max-line-length": [true, 140],
12+
"member-ordering": [true,
13+
"public-before-private",
14+
"static-before-instance",
15+
"variables-before-functions"
16+
],
17+
"no-arg": true,
18+
"no-bitwise": true,
19+
"no-console": [true,
20+
"debug",
21+
"info",
22+
"time",
23+
"timeEnd",
24+
"trace"
25+
],
26+
"no-construct": true,
27+
"no-debugger": true,
28+
"no-duplicate-key": false,
29+
"no-duplicate-variable": true,
30+
"no-empty": true,
31+
"no-eval": true,
32+
"no-shadowed-variable": true,
33+
"no-string-literal": true,
34+
"no-switch-case-fall-through": true,
35+
"no-trailing-comma": true,
36+
"no-trailing-whitespace": true,
37+
"no-unused-expression": true,
38+
"no-unused-variable": true,
39+
"no-unreachable": true,
40+
"no-use-before-declare": true,
41+
"no-var-keyword": false,
42+
"one-line": [true,
43+
"check-open-brace",
44+
"check-catch",
45+
"check-else",
46+
"check-whitespace"
47+
],
48+
"quotemark": [true, "single"],
49+
"radix": true,
50+
"semicolon": true,
51+
"sort-object-literal-keys": false,
52+
"triple-equals": [true, "allow-null-check"],
53+
"variable-name": false,
54+
"whitespace": [true,
55+
"check-branch",
56+
"check-decl",
57+
"check-operator",
58+
"check-separator",
59+
"check-type"
60+
]
61+
}
62+
}

0 commit comments

Comments
 (0)