Skip to content

Commit 9e11b40

Browse files
committed
refactor into lib
1 parent 7c8b4d6 commit 9e11b40

File tree

13 files changed

+11
-23
lines changed

13 files changed

+11
-23
lines changed

lib/build/parser/actions.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function addToTasks(result, line, index) {
4747
if (!!isActionArray) {
4848
var arrayOfActions = JSON.parse(isActionArray);
4949
arrayOfActions.forEach(function (value) {
50-
var value = trimCommandValue(cleanup_1.trimQuotes(value.trim()));
50+
value = trimCommandValue(cleanup_1.trimQuotes(value.trim()));
5151
result.chapters[index.chapter].pages[index.page].tasks[index.task].actions.push(value);
5252
});
5353
}
@@ -56,7 +56,6 @@ function addToTasks(result, line, index) {
5656
result.chapters[index.chapter].pages[index.page].tasks[index.task].actions.push(value);
5757
}
5858
return result;
59-
break;
6059
default:
6160
console.log('Invalid task action');
6261
}

lib/cli.js

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#! /usr/bin/env node
2+
23
"use strict";
34
var program = require('commander');
45
var chalk = require('chalk');
5-
var build_1 = require('./src/build/build');
6-
var create_1 = require('./src/create/create');
7-
var search_1 = require('./src/search/search');
8-
var tutorials_1 = require('./src/tutorials/tutorials');
9-
var publish_1 = require('./src/publish/publish');
10-
var docs_1 = require('./src/docs/docs');
6+
var build_1 = require('./build/build');
7+
var create_1 = require('./create/create');
8+
var search_1 = require('./search/search');
9+
var tutorials_1 = require('./tutorials/tutorials');
10+
var publish_1 = require('./publish/publish');
11+
var docs_1 = require('./docs/docs');
1112
program
1213
.version('0.3.12')
1314
.usage('[options] <keywords>')

lib/publish/validate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
var fs = require('fs');
3-
var process = require('process');
43
var chalk = require('chalk');
54
var file_1 = require('../tools/file');
65
function versionIsGreaterThanCurrent(version) {

lib/search/validate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"use strict";
2-
var process = require('process');
32
var chalk = require('chalk');
43
function validateQuery(query) {
54
if (query === 'undefined') {

lib/tutorials/tutorials.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"use strict";
2-
var process = require('process');
32
var path = require('path');
43
var chalk = require('chalk');
54
var fs = require('fs');

src/build/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as fs from 'fs';
2-
import * as process from 'process';
32
import * as validate from './validators';
43
import {project} from './parser/project';
54
import {createReadme} from './readme';

src/build/parser/actions.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {trimQuotes, trimLeadingSpaces} from './cleanup';
22
import * as Match from './match';
3-
import {brackets} from './brackets';
43

54
export function trimCommandValue(text: string): string {
65
let value = text.substring(text.indexOf('(') + 1).slice(0, -1);
@@ -11,7 +10,7 @@ export function trimCommandValue(text: string): string {
1110
return command.action + '(\'' + command.value + '\')';
1211
}
1312

14-
function doAction(type: 'test' | 'hint', isArray, actionValue, result, line, index) {
13+
function doAction(type: 'tests' | 'hints', isArray, actionValue, result, line, index) {
1514
// set to array
1615
if (result.chapters[index.chapter].pages[index.page].tasks[index.task][type] === undefined) {
1716
result.chapters[index.chapter].pages[index.page].tasks[index.task][type] = [];
@@ -28,7 +27,7 @@ function doAction(type: 'test' | 'hint', isArray, actionValue, result, line, ind
2827
return result;
2928
}
3029

31-
export function addToTasks(result, line, index): result {
30+
export function addToTasks(result, line, index) {
3231
let match = Match.isAction(line);
3332
let action = match.action; // action|test|hint|answer
3433
let task = result.chapters[index.chapter].pages[index.page].tasks[index.task];
@@ -49,7 +48,7 @@ export function addToTasks(result, line, index): result {
4948
if (!!isActionArray) {
5049
var arrayOfActions = JSON.parse(isActionArray);
5150
arrayOfActions.forEach(function(value) {
52-
let value = trimCommandValue(trimQuotes(value.trim()));
51+
value = trimCommandValue(trimQuotes(value.trim()));
5352
result.chapters[index.chapter].pages[index.page].tasks[index.task].actions.push(value);
5453
});
5554
}
@@ -58,7 +57,6 @@ export function addToTasks(result, line, index): result {
5857
result.chapters[index.chapter].pages[index.page].tasks[index.task].actions.push(value);
5958
}
6059
return result;
61-
break;
6260

6361
default:
6462
console.log('Invalid task action');

src/create/create.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
∫import * as fs from 'fs';
2-
import * as process from 'process';
32
import {validatePackageName} from './validate';
43
import {createPackageJson, createTutorialMd, createTestFiles} from './write-demo';
54
import {createReadme} from '../build/readme';

src/publish/publish.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as process from 'process';
21
import * as chalk from 'chalk';
32
import validateVersion from './validate';
43

src/publish/validate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as fs from 'fs';
2-
import * as process from 'process';
32
import * as chalk from 'chalk';
43
import {fileExists} from '../tools/file';
54

src/search/search.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as fs from 'fs';
2-
import * as process from 'process';
32
import * as chalk from 'chalk';
43
import {validateQuery} from './validate';
54
import {exec} from 'child_process';

src/search/validate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as process from 'process';
21
import * as chalk from 'chalk';
32

43
export function validateQuery(query: string) {

src/tutorials/tutorials.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as process from 'process';
21
import * as path from 'path';
32
import * as chalk from 'chalk';
43
import * as fs from 'fs';

0 commit comments

Comments
 (0)