Skip to content

Commit 93ea7ac

Browse files
committed
improved typings
1 parent ea38acb commit 93ea7ac

40 files changed

+196
-196
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
src
22
test
3-
typings
43
tsd.json
54
tsconfig.json
65
tslint.json

lib/build/build.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ var readme_1 = require('./readme');
66
var cleanup_1 = require('./parser/cleanup');
77
function build(lines) {
88
var result = {
9-
project: {},
9+
project: {
10+
title: '',
11+
description: ''
12+
},
1013
chapters: []
1114
};
1215
var index = {

lib/build/parser/actions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function doAction(type, isArray, actionValue, result, line, index) {
2727
return result;
2828
}
2929
function addToTasks(result, line, index) {
30-
var match = Match.isAction(line);
31-
var action = match.action;
30+
var action = Match.isAction(line);
3231
var task = result.chapters[index.chapter].pages[index.page].tasks[index.task];
3332
var trimmedContent = line.slice(action.length + 2, line.length - 1);
3433
var actionValue = cleanup_1.trimQuotes(trimmedContent);
@@ -40,6 +39,8 @@ function addToTasks(result, line, index) {
4039
case 'hint':
4140
result = doAction('hints', isActionArray, actionValue, result, line, index);
4241
break;
42+
case 'continue':
43+
result = doAction('continue', isActionArray, actionValue, result, line, index);
4344
case 'action':
4445
if (task.actions === undefined) {
4546
result.chapters[index.chapter].pages[index.page].tasks[index.task].actions = [];

lib/build/parser/chapter.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function chapter(result, lines, index) {
77
index.chapter += 1;
88
result.chapters.push({
99
title: Match.chapter(lines[0]).trim(),
10+
description: '',
1011
pages: []
1112
});
1213
var inCodeBlock = false;
@@ -42,9 +43,6 @@ function chapter(result, lines, index) {
4243
}
4344
exports.chapter = chapter;
4445
function addToDescription(i, result, line, index) {
45-
if (result.chapters[index.chapter].description === undefined) {
46-
result.chapters[index.chapter].description = '';
47-
}
4846
if (i > 1) {
4947
result.chapters[index.chapter].description += '\n';
5048
}

lib/build/parser/match.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ var regex = {
1212
function parseWithCode(code) {
1313
return function (line) {
1414
if (!line) {
15-
return false;
15+
return null;
1616
}
1717
if (line.match(regex[code])) {
1818
return regex[code].exec(line)[1];
1919
}
2020
else {
21-
return false;
21+
return null;
2222
}
2323
};
2424
}
@@ -33,15 +33,13 @@ exports.task = parseWithCode('+');
3333
exports.codeBlock = parseWithCode('```');
3434
exports.isArray = function (line) {
3535
var isMatch = line.match(/^\[.+\]$/);
36-
return isMatch ? isMatch[0] : false;
36+
return isMatch ? isMatch[0] : null;
3737
};
3838
exports.isAction = function (line) {
39-
var match = line.match(/^@(action|test|hint)/);
40-
return !!match ? {
41-
action: match[1]
42-
} : false;
39+
var match = line.match(/^@(action|test|hint|continue)/);
40+
return !!match ? match[1] : null;
4341
};
4442
exports.isImport = function (line) {
4543
var isMatch = line.match(/^@import\((.+)\)$/);
46-
return isMatch ? isMatch[1] : false;
44+
return isMatch ? isMatch[1] : null;
4745
};

lib/build/parser/page.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function page(result, lines, index) {
88
index.page += 1;
99
index.task = -1;
1010
result.chapters[index.chapter].pages.push({
11-
title: Match.page(lines[0]).trim()
11+
title: Match.page(lines[0]).trim(),
12+
description: ''
1213
});
1314
var inCodeBlock = false;
1415
var i = 0;
@@ -53,9 +54,6 @@ function page(result, lines, index) {
5354
exports.page = page;
5455
function addToDescriptionOrExplanation(hasBreak, i, result, line, index) {
5556
if (!hasBreak) {
56-
if (result.chapters[index.chapter].pages[index.page].description === undefined) {
57-
result.chapters[index.chapter].pages[index.page].description = '';
58-
}
5957
if (i > 1) {
6058
result.chapters[index.chapter].pages[index.page].description += '\n';
6159
}

lib/build/parser/project.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ var Match = require('./match');
33
var chapter_1 = require('./chapter');
44
var import_1 = require('./import');
55
function project(result, lines, index) {
6-
result.project = {
7-
title: '',
8-
description: ''
9-
};
106
var inCodeBlock = false;
117
var i = -1;
128
while (i < lines.length - 1) {

lib/build/readme.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ function createReadme() {
88
console.log('No coderoad.json file found');
99
return;
1010
}
11-
;
1211
if (!file_1.fileExists('./package.json')) {
1312
console.log('No package.json file found');
1413
return;
1514
}
16-
;
1715
var data = JSON.parse(fs.readFileSync('coderoad.json', 'utf8'));
1816
var packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
1917
var content = generateReadme(data, packageJson);

lib/cli.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ var create_1 = require('./create/create');
88
var search_1 = require('./search/search');
99
var tutorials_1 = require('./tutorials/tutorials');
1010
var publish_1 = require('./publish/publish');
11-
var docs_1 = require('./docs/docs');
1211
program
1312
.version('0.3.12')
1413
.usage('[options] <keywords>')
@@ -18,10 +17,9 @@ program
1817
.option('-t, --tutorials', 'list of tutorial packages')
1918
.option('-s, --search [query]', 'search for tutorial package')
2019
.option('-r, --run', 'run tutorial')
21-
.option('-d, --docs', 'development documentation')
2220
.parse(process.argv);
2321
if (!program.args.length &&
24-
!program.build && !program.tutorials && !program.run && !program.docs) {
22+
!program.build && !program.tutorials && !program.run) {
2523
program.help();
2624
}
2725
else {
@@ -47,8 +45,5 @@ else {
4745
var version = program.args[0];
4846
publish_1.default(version);
4947
}
50-
if (program.docs) {
51-
docs_1.default();
52-
}
5348
process.exit(0);
5449
}

lib/create/validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var chalk = require('chalk');
3-
var validateNpm = require("validate-npm-package-name");
3+
var validateNpm = require('validate-npm-package-name');
44
var _ = require('lodash');
55
function validatePackageName(name) {
66
var validated = validateNpm(name);

0 commit comments

Comments
 (0)